0
var box = $('.box');

$(window).on('scroll', function() {
    var top = $(window).scrollTop() + $(window).height() - 100;
    box.css('top', top);
});

http://jsfiddle.net/ALFdL/

If I scroll down a little faster, the box will like shake a little bit, is there an option like fps to adjust the scroll down frequency, I want to box move after scroll down as fast as just like fixed there.

PS: I know I can use fixed for this case, but it's just a demo code to emulate the real case.

Chan
  • 1,947
  • 6
  • 25
  • 37

2 Answers2

1

There is no necessity to use jQuery and try to fix some perormance issue when you can make this kind of box simply using CSS. Look for modified jsFiddly.

In change position property and add z-index CSS:

.box {
    width: 100px;
    height: 100px;
    background: url(http://lorempixel.com/100/100/sports/6/);
    position: fixed; 
    left: 0;
    bottom: 0;
    z-index:100;
}

So, position:fixed; makes your box fixed to the given position. z-index:100; makes it on top of other pictures.

miken32
  • 42,008
  • 16
  • 111
  • 154
Khamidulla
  • 2,927
  • 6
  • 35
  • 59
0

No. Scroll speed is determined by the browser (and usually directly by the settings on the computer/device). CSS and Javascript don't (or shouldn't) have any way to affect system settings.

See here: Can I change the scroll speed using css or jQuery?

Community
  • 1
  • 1
Web User
  • 320
  • 1
  • 7