ng-parallax
Version:
An easy way to utilize parllax scrolling in Angular apps.
1 lines • 1.28 kB
JavaScript
;"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="ngParallax"),angular.module("ngParallax",[]),angular.module("ngParallax").directive("ngParallax",["$timeout",function(a,b){return{restrict:"AE",scope:{pattern:"=",speed:"="},link:function(a,b,c){function f(){var b=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,c=b/a.speed;e&&(c=.1*c),0==c?d.style.backgroundPosition="0% 0%":d.style.backgroundPosition="0% "+c+"%"}window.mobileAndTabletcheck=function(){return!!(navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i))};var d=b[0];d.style.backgroundRepeat="repeat",d.style.backgroundAttachment="fixed",d.style.height="100%",d.style.margin="0 auto",d.style.position="relative",d.style.background="url("+a.pattern+")",d.style.backgroundAttachment="fixed";var e=window.mobileAndTabletcheck();window.document.addEventListener("touchmove",function(){f()}),window.document.addEventListener("scroll",function(){f()}),f()}}}]);