javascript event before scroll redraw?

I have a javascript function on the onscoll event to change a div’s style.

The problem is that most browsers draw the div after a scoll but before the onscoll event fires, so you end up with 1 or 2 frames where the div has the old style but the viewport is at the new scroll position. This can cause ugly flickering.

  • Detect DOMContentLoaded in iframe
  • Ember.js - Propagate event up the controller/router chain
  • How to prevent browser's default history back action for backspace button with JavaScript?
  • Does using event.preventDefault() in “mousedown” prevent “click” or “mouseup” event in jquery?
  • How to propagate event? InvalidStateError: Failed to execute 'dispatchEvent' on 'EventTarget': The event is already being dispatched
  • Input event not working if value is changed with jQuery val() or JavaScript
  • How do you prevent this?

  • How to Process PostgreSQL Triggers in a Distributed Environment
  • How do I declare event object with onclick event using Javascript (not html)?
  • Angular Ctrl click?
  • Input event not working if value is changed with jQuery val() or JavaScript
  • JQuery, bind same function to 3 different textboxs' keyup event
  • Where are Javascript event handlers stored?
  • One Solution collect form web for “javascript event before scroll redraw?”

    Maybe set the body to overflow:hidden to start, and change it to overflow:auto once the first onscroll fires.