revolunet / angular-carousel

Mobile friendly AngularJS carousel
http://revolunet.github.io/angular-carousel
MIT License
1.55k stars 705 forks source link

jumping to last or first element of carusel #212

Open jacoor opened 9 years ago

jacoor commented 9 years ago

Hello Thanks for great piece of code. I run into an issue with it. I have this code:

the thing is, that when swipeIndex > 0 and I swipe, it always jumps to first or last element - depending on swipe direction. Afterwards, it works fine. It seems like the carousel is restarting. Other curious catch - when I set swipeIndex to X (number) it is ignored. Help?

revolunet commented 9 years ago

can you please try with the new version ?

jacoor commented 9 years ago

Hmm... I did update via bower, I got, for minified version: TypeError: undefined is not a function at v (http://127.0.0.1:8000/static/libs/bower_components/angular-carousel/dist/angular-carousel.min.js:8:4280) at http://127.0.0.1:8000/static/libs/bower_components/angular-carousel/dist/angular-carousel.min.js:8:7007 at Object.fn (http://127.0.0.1:8000/static/libs/bower_components/angular/angular.min.js:108:344) at k.$digest (http://127.0.0.1:8000/static/libs/bower_components/angular/angular.min.js:109:424) at k.$apply (http://127.0.0.1:8000/static/libs/bower_components/angular/angular.min.js:112:398) at h (http://127.0.0.1:8000/static/libs/bower_components/angular/angular.min.js:72:454) at u (http://127.0.0.1:8000/static/libs/bower_components/angular/angular.min.js:77:463) at XMLHttpRequest.z.onreadystatechange (http://127.0.0.1:8000/static/libs/bower_components/angular/angular.min.js:79:24)

For full: TypeError: undefined is not a function at goToSlide (http://127.0.0.1:8000/static/libs/bower_components/angular-carousel/dist/angular-carousel.js:373:45) at http://127.0.0.1:8000/static/libs/bower_components/angular-carousel/dist/angular-carousel.js:500:33 at Object.fn (http://127.0.0.1:8000/static/libs/bower_components/angular/angular.min.js:108:344) at k.$digest (http://127.0.0.1:8000/static/libs/bower_components/angular/angular.min.js:109:424) at k.$apply (http://127.0.0.1:8000/static/libs/bower_components/angular/angular.min.js:112:398) at h (http://127.0.0.1:8000/static/libs/bower_components/angular/angular.min.js:72:454) at u (http://127.0.0.1:8000/static/libs/bower_components/angular/angular.min.js:77:463) at XMLHttpRequest.z.onreadystatechange (http://127.0.0.1:8000/static/libs/bower_components/angular/angular.min.js:79:24)

seems like var tweenable = new Tweenable(); this fails.

jacoor commented 9 years ago

One issue one be I am using require.js for this project and this 'angular-carousel.shifty' doesn't want to cooperate in this enviroment.

revolunet commented 9 years ago

ho bad. can you please check in your angular-carousel.js if you have the 'angular-carousel.shifty' module defined ? not sure if its a bower issue or not

jacoor commented 9 years ago

Yes, it's there. I added console.log(angular.module('angular-carousel.shifty'));

just before calling this var tweenable = new Tweenable(); - below is console.log.

Object {_invokeQueue: Array[1], _runBlocks: Array[0], requires: Array[0], name: "angular-carousel.shifty", provider: function…}_invokeQueue: Array[1]_runBlocks: Array[0]animation: function (){ce||"push";return n}config: function (){ce||"push";return n}constant: function (){ce||"push";return n}controller: function (){ce||"push";return n}directive: function (){ce||"push";return n}factory: function (){ce||"push";return n}filter: function (){ce||"push";return n}name: "angular-carousel.shifty"provider: function (){ce||"push";return n}requires: Array[0]run: function (a){d.push(a);return this}service: function (){ce||"push";return n}value: function (){ce||"push";return n}proto: Object

revolunet commented 9 years ago

i'm not a requirejs user so i'm not sure how to resolve this :/ any idea ?

jacoor commented 9 years ago

I'd start with separating modules into separate files for require to work.. But that's just a guess right now. I'll give it a shot when I have a bit fresher mind and I'll check what I can do.

revolunet commented 9 years ago

about requirejs, some contributor fixed the problem in the 0.3.4 version. can you confirm please ?

jacoor commented 9 years ago

I'll check. Thanks for update. Jacek 30 pa¼ 2014 03:17 "Julien Bouquillon" notifications@github.com napisa³(a):

about requirejs, some contributor fixed the problem in the 0.3.4 version. can you confirm please ?

Reply to this email directly or view it on GitHub https://github.com/revolunet/angular-carousel/issues/212#issuecomment-61036472 .

jacoor commented 9 years ago

I see that some css have changed which makes in kinda hard to test, but from what I see:

jacoor commented 9 years ago

I have a feelign I might know why there is an issue. Sometime ago I reported you a bug that when I do carouselIndex+1 it adds strings, not numbers. Therefore if sometimes wents crazy. So, I created myself a watcher and some values: $scope.swipeIndex = { value: index, value1: index+1, value_1: index-1, };

    $scope.$watch('swipeIndex.value', function(newValue, oldValue){
        $scope.swipeIndex.value1 = parseInt(newValue)+1;
        $scope.swipeIndex.value_1 = parseInt(newValue)-1;
    });

This way it works properly. I can not use your nextSlide() and prevSlide() functions because I use those controls out of ng-carousel list. You may close it, I consider it working however tricky. Thanks again for help and great plugin.