Initial commit
This commit is contained in:
17
wp-content/plugins/gp-premium/elements/assets/js/parallax.js
Normal file
17
wp-content/plugins/gp-premium/elements/assets/js/parallax.js
Normal file
@ -0,0 +1,17 @@
|
||||
function generate_parallax_element( selector, context ) {
|
||||
context = context || document;
|
||||
var elements = context.querySelectorAll( selector );
|
||||
return Array.prototype.slice.call( elements );
|
||||
}
|
||||
|
||||
window.addEventListener( "scroll", function() {
|
||||
var scrolledHeight= window.pageYOffset;
|
||||
generate_parallax_element( ".page-hero" ).forEach( function( el, index, array ) {
|
||||
var limit = el.offsetTop + el.offsetHeight;
|
||||
if( scrolledHeight > el.offsetTop && scrolledHeight <= limit ) {
|
||||
el.style.backgroundPositionY = ( scrolledHeight - el.offsetTop ) / hero.parallax + "px";
|
||||
} else {
|
||||
el.style.backgroundPositionY = "0";
|
||||
}
|
||||
});
|
||||
});
|
1
wp-content/plugins/gp-premium/elements/assets/js/parallax.min.js
vendored
Normal file
1
wp-content/plugins/gp-premium/elements/assets/js/parallax.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
function generate_parallax_element(e,o){var t=(o=o||document).querySelectorAll(e);return Array.prototype.slice.call(t)}window.addEventListener("scroll",function(){var r=window.pageYOffset;generate_parallax_element(".page-hero").forEach(function(e,o,t){var a=e.offsetTop+e.offsetHeight;r>e.offsetTop&&r<=a?e.style.backgroundPositionY=(r-e.offsetTop)/hero.parallax+"px":e.style.backgroundPositionY="0"})});
|
Reference in New Issue
Block a user