angular-swiper
angular-swiper copied to clipboard
AutoPlay dosen't work?
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>
The issue maybe with ng-repeat/dynamically loading images. Does autoplay continue to work when you resize the browser after you finish loading images?
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.
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>
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.