Note that there are some explanatory texts on larger screens.

plurals
  1. POissue runing script on page render vs page load, in webkit
    primarykey
    data
    text
    <p>I have a script that uses some element offsets. I intended to fire this script with : </p> <pre><code>window.addEventListener('load', function() { ... } </code></pre> <p>When I use this method, all of the DOM elements are defined but the offset values are wrong. I can get the provided offsets by turning off some css values. A quick / terrible fix I applied : </p> <pre><code>window.addEventListener('load', function() { function my_func(){ ... } window.setTimeout(my_func, 1000); }); </code></pre> <p>This renders the correct offsets, but I just feel like its duct tape. </p> <p>My last attempt was to force webkit to render, but this also had the wrong offsets :</p> <pre><code> window.addEventListener('load', function() { function my_func(){ ... } document.getElementById('wrap').style.display = 'none'; document.getElementById('wrap').style.display = 'block'; my_func(); }); </code></pre> <p>Any sugestions? or an explanation of why this happens. The browser I was testing with is Chrome.</p> <p>EDIT : </p> <p>The offsets are of a dom structure :</p> <pre><code>&lt;div id="wrap"&gt; &lt;div&gt; &lt;p&gt;...&lt;/p&gt; &lt;p&gt;...&lt;/p&gt; &lt;p&gt;...&lt;/p&gt; &lt;/div&gt; &lt;div&gt; &lt;p&gt;...&lt;/p&gt; &lt;/div&gt; ... &lt;/div&gt; </code></pre> <p>I access the offsets by (for)lopping over the node list of "#wrap div". If I turn off line-height and font-size I will get the offset that is calculated before the layout is fully rendered. </p> <p>Adjusting line-height, font-size and display for each p and div before using offsetHeight, has no affect. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload