forcedotcom / scrollerjs

A JavaScript library that helps you build performant UI components for the web.
http://scrollerjs.com
Apache License 2.0
636 stars 63 forks source link

Wrong Indicator scroller position #12

Closed sucotronic closed 9 years ago

sucotronic commented 9 years ago

It seems that the browser is not calling as many times as needed to the _move function that is defined for the 'mousemove' event, so when the indicator is dragged, the positions are not being calculated correctly. If you move the cursor slowly, it works ok, but when you drag at normal speed, some distance appears between the cursor and the scroll position.

Demonstration video:

https://www.dropbox.com/s/f5uy84snu2vkap4/scrollerJs1.webm?dl=0

The other related issue is the wrong offset position stored in thix.x and this.y when the drag action is continued out of the wrapper.

Demonstration video:

https://www.dropbox.com/s/svmci4pvzbqs0zj/scrollerJs2.webm?dl=0

I'm able to fix this behaviour (more or less) with the following lines in the _move function:

        newX = point.pageX - this.wrapper.getBoundingClientRect().left;
        newY = point.pageY - this.wrapper.getBoundingClientRect().top;

I would do a PR with my fix, but I suspect that there'll be a more elegant way to fix this, no?