Frage

I currently have two jQuery scripts running on a single div -- one is an instance of jScrollPane, and the other is a custom script that relies on the current value of of scrollLeft() insdie the div.

Only one of these scripts could work at once. After a lot of digging around, I found that when jScrollPane was running, the value of scrollLeft() has failed to update when I scrolled inside the div.

After a scan through the jquery.jscrollpane.js file, I couldn't find any instance where scrollLeft() was fixed, but I could be wrong.

Is there any way I could force the scrollLeft() value to continuously update itself in spite of whatever jScrollPane is doing?

War es hilfreich?

Lösung

Okay! So after more digging we find: jScrollPane doesn't actually scroll the content -- it emulates scrolling but continuously resetting the left value of whatever it's applied to. So, if you need the value of scrollLeft(), you can get it with jScrollPane's getContentPositionX() function.

Note that when you do use this function, one must first call .data('jsp'), like such:

var scrollLeft = $('#div-id').data('jsp').getContentPositionX();

Also note that this works the same for scrollTop() and getContentPositionY().

scrollLeft() never updated because we were never really scrolling.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top