[英]Swipe user media cards left/right to reveal next one
I am trying to implement a widget which ng-repeats
user media objects horizontally and I should be able to swipe left/right to reveal the next media card. 我正在尝试实现一个小部件,它可以水平
ng-repeats
用户媒体对象,我应该能够向左/向右滑动以显示下一个媒体卡。 widget should look something like this 小部件应该看起来像这样
As you can see the image 你可以看到图像
The next card avatar is half visible, hinting there are more cards to swipe. 下一张卡片头像是半可见的,暗示有更多卡片可以刷卡。
this is all i have currently.. i am stuck here 这就是我目前所有的......我被困在这里
div class="media people-card-media col-xs-12" ng-repeat="item in cats">
<div class="media-left ">
<div class="person-photo presence" >
<img class="media-object list__photo img-circle" ng-src="{{item.photo}}" />
</div>
</div>
<div class="media-body list__body">
<div class="people_name_title">
<h4 class="media-heading title">{{item.name}}</h4>
</div>
</div>
<div class="media-right media-middle contacts-chat-call flex-it-align-top">
<a style="margin-right: 10px;">
call
</a>
</div>
</div>
heres the plunker http://plnkr.co/edit/YESgpGIXQrK9sYl79FVI?p=preview 继承人http://plnkr.co/edit/YESgpGIXQrK9sYl79FVI?p=preview
Here is a plunkr with a working implementation. 这是一个具有工作实现的plunkr。
http://plnkr.co/edit/wmIyCFM57hniZQ82Z8Ba?p=preview http://plnkr.co/edit/wmIyCFM57hniZQ82Z8Ba?p=preview
I added ngTouch and in the HTML a ng-class
and the touch event handlers. 我加入ngTouch和在HTML中的
ng-class
和触摸事件处理程序。
<div class="media people-card-media col-xs-12"
ng-class="item.displayClass"
ng-repeat="item in heroes"
ng-click="gonext()"
ng-swipe-left="gonext()"
ng-swipe-right="goprev()">
And in the MainController, it flips through active item by assigning a current
class to it, and a next-up
and previous
class to the neighbors. 而在MainController,它通过分配翻阅活动项
current
类给它,并且next-up
和previous
类邻居。
$scope.gonext = function () {
for (var i=0, len=$scope.heroes.length; i<len; i++) {
if ($scope.heroes[i].displayClass == 'current') {
$scope.heroes[i].displayClass = 'previous';
if (i<len-1) $scope.heroes[i+1].displayClass = 'current';
if (i<len-2) $scope.heroes[i+2].displayClass = 'next-up';
i=len;
};
};
};
Only needs a better handling of the boundaries. 只需要更好地处理边界。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.