Last active
January 22, 2018 01:35
-
-
Save KoryNunn/722e134275df978cb70aaa65c837c4bc to your computer and use it in GitHub Desktop.
Background Task Defer Request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function onDrag(event){ | |
| if(!dragging){ | |
| return | |
| } | |
| // Tell the browser you are doing important stuff | |
| // It will decide whether or not to delay background tasks for a small period of time | |
| // For example, not doing garbage collection if it isn't really critical. | |
| // It might also decided not to, if it NEEDS to GC, or paint, or anything. | |
| window.requestBackgroundTaskDefer(); | |
| // Obvs use css transforms but you get the idea. | |
| someElement.top = event.pageY + 'px'; | |
| someElement.left = event.pageX + 'px'; | |
| } | |
| window.addEventListener('mousemove', onDrag); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I already miss the stupid version