-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scroll-change event and scrollTo method #183
Comments
Wouldn't this decrease scrolling performance? It still could be implemented as a separate module. |
I think browsers are smart enough to not let it effect scrolling performance. |
I think that the event and method should be in core. |
Scroll events are not implemented in Quill but might be reasonable to add. What would a desirable API look like? I believe natively, browsers will fire the scroll event even when scrolled 1px though there may be some maximum fire rate. This probably is not a big issue unless users attach a listener that does a lot of computation so Quill might want to limit this rate even more. Alternatively this event could be asynchronous and would not re-fire until all listeners callbacks have returned. Also what information should the scroll event provide? |
How about this API? // event
editor.on('scroll', function(scrollLeft, scrollTop) {
});
//setters
editor.scrollTo(x, y);
editor.scrollTop(y);
editor.scrollLeft(x);
//getters
editor.scrollTop();
editor.scrollLeft(); Simplest option is to just fire the event (like CodeMirror does) and leave throttling to the user. It's possible to throttle the scroll event. When the browser fires the event, we could start a timeout. If another scroll event is fired, cancel the timeout and create a new timeout. When the timeout fires, dispatch the editor's scroll event. |
A nice idea to debounce the scroll event with requestAnimationFrame |
Wish there was a way in JS to return multiple values to avoid two APIs for top and left. Is there a feature you are trying to build that would use these APIs? |
I actually just need scrollTop. |
With v0.19 Quill no longer hides the editor in an iframe so using DOM events and apis directly should be sufficient for this. |
Is it possible to add 'scroll-change' event that fire when a user is scrolling (or finished scrolling) with scrollTop?
I couldn't find this event in the list:
https://github.com/quilljs/quill/blob/develop/src/quill.coffee#L48
It will also be useful to have quill.editor.scrollTo method that will let us scroll the editor.
Thanks
The text was updated successfully, but these errors were encountered: