Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determining even and odd #26

Open
sdkevorkian opened this issue Jun 21, 2017 · 0 comments
Open

Determining even and odd #26

sdkevorkian opened this issue Jun 21, 2017 · 0 comments

Comments

@sdkevorkian
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant