universal-parallax
Advanced tools
Comparing version 1.0.11 to 1.0.12
/** | ||
* @version 1.0.11 | ||
* @version 1.0.12 | ||
* @author Marius Hansen <marius.o.hansen@gmail.com> | ||
@@ -81,5 +81,6 @@ * @license MIT | ||
parallaxContainer.className += 'parallax--container'; | ||
// parent elem need position: relative for effect to work - if not already defined, add it | ||
if (window.getComputedStyle(parallaxContainer.parentElement, null).getPropertyValue('position') !== 'relative') { | ||
this.style.position = 'relative'; | ||
parallaxContainer.parentElement.style.position = 'relative'; | ||
} | ||
@@ -86,0 +87,0 @@ |
@@ -1,1 +0,1 @@ | ||
function calculateHeight(e,a){for(var t=0;e.length>t;t++){var n=e[t].parentElement.scrollHeight,i=(window.innerHeight-n)/2,l=n+2*(i-i/a);e[t].style.height=l+"px"}}function animateParallax(e,a){for(var t=0;e.length>t;t++){var n=e[t].parentElement.getBoundingClientRect().top/a;e[t].style.top=n+"px"}}var universalParallax=function(){var e=function(e,a){a<1.2&&(a=0),/Mobi/.test(navigator.userAgent)?pageHeight=screen.height:pageHeight=window.innerHeight,calculateHeight(e,a),window.addEventListener("resize",function(){calculateHeight(e,a)}),window.addEventListener("scroll",function(){animateParallax(e,a)})};this.init=function(a){void 0===a&&(a={}),a={speed:void 0!==a.speed?a.speed:4,className:void 0!==a.className?a.className:"parallax"};for(var t=document.getElementsByClassName(a.className),n=0;t.length>n;n++){var i=document.createElement("div");t[n].parentNode.insertBefore(i,t[n]),i.appendChild(t[n]);var l=t[n].parentElement;l.className+="parallax--container","relative"!==window.getComputedStyle(l.parentElement,null).getPropertyValue("position")&&(this.style.position="relative");var r=t[n].dataset.parallaxImage;void 0!==r&&(t[n].style.backgroundImage="url("+r+")",1===t[n].classList.length&&"parallax"===t[n].classList[0]&&Object.assign(t[n].style,{"background-repeat":"no-repeat","background-position":"center","background-size":"cover"}))}e(t,a.speed)}}; | ||
function calculateHeight(e,a){for(var t=0;e.length>t;t++){var n=e[t].parentElement.scrollHeight,l=(window.innerHeight-n)/2,i=n+2*(l-l/a);e[t].style.height=i+"px"}}function animateParallax(e,a){for(var t=0;e.length>t;t++){var n=e[t].parentElement.getBoundingClientRect().top/a;e[t].style.top=n+"px"}}var universalParallax=function(){this.init=function(e){void 0===e&&(e={}),e={speed:void 0!==e.speed?e.speed:4,className:void 0!==e.className?e.className:"parallax"};for(var a,t,n=document.getElementsByClassName(e.className),l=0;n.length>l;l++){var i=document.createElement("div");n[l].parentNode.insertBefore(i,n[l]),i.appendChild(n[l]);var r=n[l].parentElement;r.className+="parallax--container","relative"!==window.getComputedStyle(r.parentElement,null).getPropertyValue("position")&&(r.parentElement.style.position="relative");var s=n[l].dataset.parallaxImage;void 0!==s&&(n[l].style.backgroundImage="url("+s+")",1===n[l].classList.length&&"parallax"===n[l].classList[0]&&Object.assign(n[l].style,{"background-repeat":"no-repeat","background-position":"center","background-size":"cover"}))}a=n,(t=e.speed)<1.2&&(t=0),/Mobi/.test(navigator.userAgent)?pageHeight=screen.height:pageHeight=window.innerHeight,calculateHeight(a,t),window.addEventListener("resize",function(){calculateHeight(a,t)}),window.addEventListener("scroll",function(){animateParallax(a,t)})}}; |
{ | ||
"name": "universal-parallax", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "Easy parallax plugin using pure javascript. Also works on mobile platforms. Cross browser support.", | ||
@@ -5,0 +5,0 @@ "main": "dist/universal-parallax.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1819666