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
Passive event listeners #4292
Comments
Key events aren't fired for scrolling, so I'm not sure how this would help. Doing less heavy computations in your key handlers, or splitting the work up in smaller slices using setTimeout, seems like a more promising approach. |
Thanks for the tip @marijnh. I tried to delay the whole computation using setTimeout but it doesn't work inside CodeMirror. Although it works with a regular textarea. Here is a jsfiddle for the repro: https://jsfiddle.net/viebel/9f1hojuq/12/ Any help will be much appreciated. |
An infinite loop is always going to break your page. That's how JavaScript works -- non-web-worker scripts are run on a single thread and block the page. |
I know. But in some cases, page scroll is not blocked. Take a look at the On Mon, Oct 10, 2016, 10:56 Marijn Haverbeke notifications@github.com
|
I guess if you don't register an active scroll listener you can still scroll a stuck page. (I'm not sure why, since scroll events only fire after the actual scrolling happens anyway). But CodeMirror needs a scroll listener, so that's just not going to work with CodeMirror. (And your user experience will still be terrible if your script is working for long periods of time, even if scrolling continues to work.) |
My use case is for a blog post with code snippets so the experience would Anyway, why does CodeMirror need a scroll listener? On Mon, 10 Oct 2016 at 11:03 Marijn Haverbeke notifications@github.com
|
To keep its viewport in sync with the scroll position, and to keep the gutter in place.
No. |
I'd like to have a pasive event listener https://developers.google.com/web/updates/2016/06/passive-event-listeners
to handle an extraKey event.
Is there a way to configure a passive event listener in CodeMirror?
The rationale is that I'm doing heavy computation when the extraKey is triggered and I don't want the page scrolling to be stuck.
The text was updated successfully, but these errors were encountered: