1234567891011121314151617181920212223242526272829303132333435363738 |
- app.directive('scroll', ['$window','$timeout',function($window,$timeout) {
- return {
- restrict: 'A',
- scope: {
- offset: '@',
- offsetSecond: '@',
- scrollClass: '@',
- scrollClassSecond: '@',
- scrollClassThird: '@'
- },
- link: function(scope, element) {
- var canIHover = function(){
- element.removeClass(scope.scrollClassThird);
- $timeout(function(){
- element.addClass(scope.scrollClassThird);
- },1000)
- }
- var windowJQ = angular.element($window)
- windowJQ.bind("scroll", function() {
- if (window.pageYOffset >= parseInt(scope.offset)) {
- element.addClass(scope.scrollClass);
- canIHover();
- } else {
- element.removeClass(scope.scrollClass);
- canIHover();
- }
- if(window.pageYOffset >= parseInt(scope.offsetSecond)){
- element.addClass(scope.scrollClassSecond);
- canIHover();
- } else {
- element.removeClass(scope.scrollClassSecond);
- canIHover();
- }
- });
- }
- };
- }])
|