if ($('.parallax.scroll').length > 0 && !isMobile.any()) {
$('.parallax.scroll').each(function() {
var $bgobj = $(this);
$(window).scroll(function() {
var yPos = -(getCurrentScroll() / $bgobj.data('speed'));
var coords = '50% '+ yPos + 'px';
$bgobj.css({ backgroundPosition: coords });
});
});
}
// usage
//<div class="parallax scroll" data-speed="4" style="background-image: url('/path/to/image.ext')"></div>
Smooth parallax effect for background images on scroll (images move with scroll)
Needs css - https://codepad.co/snippet/uJsRRXJB - to work properly.
Needs css - https://codepad.co/snippet/uJsRRXJB - to work properly.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.