davetayls / jquery.kinetic

Add kinetic scrolling functionality to a container using mouse or touch devices
http://davetayls.me/jquery.kinetic
MIT License
420 stars 86 forks source link

Make the listeners return current scroll positions. #79

Closed ZwaarContrast closed 9 years ago

ZwaarContrast commented 9 years ago

I propose implementing a system where the listeners for moved and stopped return the current scroll position.

Can probably by realised by changing Kinetic.prototype.stop and change the line this.settings.stopped.call(this); to this.settings.stopped.call(this,settings,{left: this.scrollLeft(),top: this.scrollTop());

According to the current documentation the stopped function also returns the settings, which it doesn't. It does work as documented in the moved function. This is fixed in the above mentioned change.

Should also be changed in Kinetic.prototype._move. Change settings.moved.call(this, settings); to this.settings.moved.call(this,settings,{left: this.scrollLeft(),top: this.scrollTop());

davetayls commented 9 years ago

this isn't really needed anymore since you can just access the current instance within the moved function ie:

moved: function() { console.log(this.scrollLeft()); }

good spot that the docs are outdated though

ZwaarContrast commented 9 years ago

Alright, didn't know that I could access the instance from inside the callback. Good call, thanks!

davetayls commented 9 years ago

no worries, i've updated the docs :smile: