Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok -- wiping my old answer and replacing...</p> <p>Here's your problem:</p> <p>You are taking and comparing window and document height, without first taking into consideration the order of events here..</p> <ol> <li>Window loads</li> <li>Div grows to window height</li> <li>Window shrinks</li> <li>Document height remains at div height</li> <li>Window height is less than div height</li> </ol> <p>At this point, the previously set height of the div is keeping document height greater than the window height, and this logic is misinterpreted: "Scrolling needed, no need to extend the sidebar" fires, erroneously</p> <p>Hence the twitch.</p> <p>To prevent it, just resize your div along with the window before making the comparison:</p> <pre><code>(function () { var resizeContentWrapper = function () { console.group('resizing'); var target = { content: $('#resizeme') }; //resize target content to window size, assuming that last time around it was set to document height, and might be pushing document height beyond window after resize //TODO: for performance, insert flags to only do this if the window is shrinking, and the div has already been resized target.content.css('height', $(window).height()); var height = { document: $(document).height(), window: $(window).height() }; console.log('height: ', height); if (height.document &gt; height.window) { // Scrolling needed, no need to externd the sidebar target.content.css('height', ''); console.info('custom height removed'); } else { // Set the new content height height['content'] = height.window; target.content.css('height', height['content']); console.log('new height: ', height); } console.groupEnd(); } resizeContentWrapper(); $(window).bind('resize orientationchange', resizeContentWrapper); })(jQuery); </code></pre> <p>Per pmvdb's comment, i renamed your $$ to "target"</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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