angular-swiper icon indicating copy to clipboard operation
angular-swiper copied to clipboard

AutoPlay dosen't work?

Open Turifan opened this issue 9 years ago • 4 comments

I used angular-swiper in my project, but AutoPlay dosen't work. My code follow:

Please suggest me how i can make it work, thanks! <ks-swiper-container slides-per-view="1" slides-per-column="1" space-between="0" pagination-is-active="true" pagination-clickable="true" show-nav-buttons="false" loop="true" autoplay="2000" initial-slide="0" direction="horizontal"> <ks-swiper-slide class="swiper-slide" ng-repeat="list in listBean"> <a ng-href="{{list.companyURL}}"> <img ng-src="/{{list.companyImg}}" alt="{{list.companyName}}" class="img-responsive"> </a> </ks-swiper-slide> </ks-swiper-container>

Turifan avatar Oct 13 '16 09:10 Turifan

The issue maybe with ng-repeat/dynamically loading images. Does autoplay continue to work when you resize the browser after you finish loading images?

brh55 avatar Nov 16 '16 18:11 brh55

It can work when I add $timeout in the code

Get Outlook for iOShttps://aka.ms/o0ukef

On Thu, Nov 17, 2016 at 2:15 AM +0800, "Brandon Him" <[email protected]mailto:[email protected]> wrote:

The issue maybe with ng-repeat/dynamically loading images. Does autoplay continue to work when you resize the browser after you finish loading images?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ksachdeva/angular-swiper/issues/53#issuecomment-261025823, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AP5UrFThk1k8kQ39tKSgEM-yhG_osSQkks5q-0gbgaJpZM4KVrPd.

Turifan avatar Nov 28 '16 03:11 Turifan

add ng-if, My code follow: <ks-swiper-container ng-if="home.bannerContent[0] && home.bannerContent[0].content.length>0" autoplay="3000" loop="true" on-ready="onReadySwiper(swiper)" pagination-is-active="true" > <ks-swiper-slide class="swiper-slide" ng-repeat="item in home.bannerContent[0].content"> <a ng-href="{{item.linkUrl}}"> <img ng-src="{{item.imgUrl}}" alt="" /> </a> </ks-swiper-slide> </ks-swiper-container>

WillisYe avatar Dec 29 '16 09:12 WillisYe

For anyone still struggling with this issue please notice that currently Swiper itself expects an object (w/ delay as one of its properties).

And angular-swiper does a type checking to make sure the param is a number.

if (!angular.isUndefined($scope.autoplay) && typeof $scope.autoplay === 'number') {
    params = angular.extend({}, params, {
        autoplay: $scope.autoplay
    });
}

So it's impossible to get the autoplay to work without updating angular-swiper source to avoid this type check.

fbanyai avatar Nov 29 '18 16:11 fbanyai