滑块可以工作,但可以一直持续下去。最后一张照片来时,我要你停下来。我该如何阻止它?
指令:-
app.directive('swipeSlider', function() {
return {
link: link,
scope: {dir: '='},
}
function link(scope, element, attrs) {
var wdth = $(window).width();
$(element).mousedown(function (e) {
var strt = e.pageX;
var lft = $(element).children("div").offset().left
$(this).mousemove(function (e) {
if(strt+10 < e.pageX){
$(element).children("div").css('margin-left', lft + ( wdth / 3 ) );
}
if(strt-10 > e.pageX){
$(element).children("div").css('margin-left', lft - ( wdth / 3 ) );
}
});
}).mouseup(function (e) {
$(this).unbind('mousemove');
})
.mouseout(function (e) {
$(this).unbind('mousemove');
})
}
});
HTML:-
<div id="elm{{$index}}" class="col-sm-12 hSlideHolder" swipe-slider>
<div>
<div class="hSlide noselect" ng-repeat="pl_itm in itm.playlistContent">
<img src="{{ addImg( pl_itm.worldPosterArt ) }}" class="thumbImg">
</div>
</div>
</div>
对不起,我的英语不好。 image1