angular-scroll-animate icon indicating copy to clipboard operation
angular-scroll-animate copied to clipboard

Determining even and odd

Open sdkevorkian opened this issue 7 years ago • 0 comments

Hello! I am trying to pass the index into the when-visible directive so that I have alternating scroll effects. Here is what I have working:

 <div class="col s12 project not-visible animated" ng-repeat="project in projects track by $index" when-visible="animateElementIn" delay-percent="0.33">
</div>
...
        $scope.animateElementIn = function($el) {
            $el.removeClass('not-visible');
            $el.addClass('fadeInLeftBig');
        };

I tried to pass both $el and $index in like this:

when-visible="animateElementIn($el, $index)" 
...
        $scope.animateElementIn = function($el, $index) {
            $el.removeClass('not-visible');
            $el.addClass('fadeInLeftBig');
        };

but I get this error:

angular.js:13236 TypeError: Cannot read property 'removeClass' of undefined at ChildScope.$scope.animateElementIn (file:///home/sara/portfolio/js/app.js:7:16) at fn (eval at compile (http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:14086:15), :4:386) at Scope.destination.(anonymous function) [as whenVisible] (http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:9603:22) at new controller (file:///home/sara/portfolio/angular-scroll-animate/dist/angular-scroll-animate.js:82:61) at Object.invoke (http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:4604:19) at extend.instance (http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:9855:34) at nodeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:8927:34) at compositeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:8226:13) at publicLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:8106:30) at http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:8447:29

is there a way to access the index (or odd/even) within the function called from where-visible?

sdkevorkian avatar Jun 21 '17 01:06 sdkevorkian