[jQuery] Optimize Horizontal Scroll Interface
Hello Peoples.
I have been working on an interface using the jquery plugin ScrollTo.
I have large left and right buttons which scroll the page content left
and right.
10 items are displayed at a time, when the visitor is on item 10 the
left and right buttons load the page with next or previous ten items.
Here is the testing page:
http://www.kith-kin.co.uk/xmas08/studio/
I needed to find out which item was being 'viewed' so the buttons
would perform correctly, even if the page was manually scrolled.
I count which item was being viewed by taking the scroll offset and
then looping through the width of the content. I think this
could be improved, I am not that well versed in javascript / jquery.
Here is the js, the calculation is in the scroll function.
http://www.kith-kin.co.uk/js/09/studio/kithkin.js
Can I do this calculation only on horizontal scroll, jquery's method
seems
to be for both vertical and horizontal.
Or could i run the calculation only at the end of scrolling, not
whilst scrolling?
Any tips or suggestions would be ace, im still learning!
Cheers.
Ian.