Reputation: 3
I am trying to make a sort of parallax webdesign. My question is, if someone knows how I can make the red div move faster. I think its in the formule but dont know sure. Maybe someone knows?
Here is my code: http://jsfiddle.net/PvVdq/
$(document).ready(function () {
var $horizontal = $('#horizontal');
$(window).scroll(function () {
var s = $(this).scrollTop(),
d = $(document).height(),
c = $(this).height();
scrollPercent = (s / (d - c));
var position = (scrollPercent * ($(document).width() - $horizontal.width()));
$horizontal.css({
'left': position
});
});
});
Upvotes: 0
Views: 145
Reputation: 3441
Yuo need to play with your scrollPercent , if you want it go faster :
scrollPercent = (s / (d - c) * 2);//twice fatser
or even faster :
scrollPercent = (s / (d - c) * 3);//3 times fatser
http://jsfiddle.net/PvVdq/1448/
Upvotes: 0
Reputation: 118
I'm not so sure about this. When I tried this one, it speeds up the movement of the red div
$(document).ready(function () {
var $horizontal = $('#horizontal');
$(window).scroll(function () {
var s = $(this).scrollTop(),
d = $(document).height(),
c = $(this).height();
scrollPercent = (s / (d - c));
var position = (scrollPercent * 10 * ($(document).width() - $horizontal.width()));
$horizontal.css({
'left': position
});
});
});
Upvotes: 1