1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| (function ($) {
$(document).ready(function() {
var heightcol1 = $("#scroll1").innerHeight();
var heightcol2 = $("#scroll2").innerHeight();
var heightcol3 = $("#scroll3").innerHeight();
// calcul du nbr de colonnes
var parallaxElements = $('.col'),
parallaxQuantity = parallaxElements.length;
// création de la fonction scroll
$(window).on('scroll', function () {
window.requestAnimationFrame(function () {
for (var i = 0; i < parallaxQuantity; i++) {
var scrolled = $(window).scrollTop();
$('.large-translate').css({
'transform': 'translate3d(0,' + scrolled * -0.00003 + 'px, 0)'
});
$('.medium-translate').css({
'transform': 'translate3d(0,' + scrolled * -0.2 + 'px, 0)'
});
$('.small-translate').css({
'transform': 'translate3d(0,' + scrolled * -0.6 + 'px, 0)'
});
}
});
});
});
}(jQuery)); |
Partager