Skip to content

Instantly share code, notes, and snippets.

@KoryNunn
Last active January 22, 2018 01:35
Show Gist options
  • Select an option

  • Save KoryNunn/722e134275df978cb70aaa65c837c4bc to your computer and use it in GitHub Desktop.

Select an option

Save KoryNunn/722e134275df978cb70aaa65c837c4bc to your computer and use it in GitHub Desktop.
Background Task Defer Request
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);
@MichaelZaporozhets
Copy link

I already miss the stupid version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment