views:

165

answers:

2

hi all,

i'm having a scrollable table with fixed header. would it be possible to have "snapped scrolling" on the scrollbar - which means that the table rows won't scroll pixel by pixel but snap responding to its row height, for better viewing.

thx

+1  A: 

the answer is 'yes' .. you can adjust .scrollTop and make it be anything you want in response to an onscroll event

read about scrollTop here

read about the scroll event here

Scott Evernden
nice - i figured out how to do it - here's my code: tBody.scroll(function(valu){ var nu = Math.ceil($(this).scrollTop()/17)*17; $(this).scrollTop(nu); });the problem: the "default" scrolling when moving the scrollbar is intersecting with my new valung, thus causing to have the content around - is there a way to disable this kind of default scrolling?
Fuxi
sorry saved too early - i meant it is JUMPING around
Fuxi
If I was doing this, I'd let the table scroll the way it wants but after the button is released I would $().animate() scrolltop up or down to the whole-row position you want
Scott Evernden
A: 

What I would do is have a 0px-wide Dummy DIV—with a scrollbar—set to the same height as the Target DIV—with no scrollbar.

I would then track the scroll-offset of the Dummy DIV for setting the Target DIV's scroll attribute. It would feel fluid, natural, and the most transparent to the user, which is really important for a good experience.

Jonathan Gordon