如何使用指令停止图像滑块?

时间:2018-07-24 12:33:25

标签: angularjs angularjs-directive slider

滑块可以工作,但可以一直持续下去。最后一张照片来时,我要你停下来。我该如何阻止它?

指令:-

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

image2

0 个答案:

没有答案
相关问题