Note that there are some explanatory texts on larger screens.

plurals
  1. POExpandable unordered list animation, rendering issue
    primarykey
    data
    text
    <p>I am trying to animate an expandable list, but having trouble in correctly displaying list. Without animation effect list is being displayed correctly (expand/collapse). To collapse list I am using <code>ul.style.visibility = "hidden"; ul.style.height = "0px";</code>. Without animation effect, list if looking fine:</p> <p><img src="https://i.stack.imgur.com/xGxDH.jpg" alt="Correctly displayed unordered list">. </p> <p>The black borders are on UL element. I am using following Javascript code to expand the list:</p> <pre><code>var from = 0; //The height ul.style.height = "auto"; //set height to auto to get actual height var to = ul.offsetHeight; //get height ul.style.height = "0px"; ul.style.visibility = "visible"; ul.style.overflow = "hidden"; var start = new Date().getTime(), timer = setInterval(function() { var step = Math.min(1,(new Date().getTime()-start)/400); ul.style.height = (from+step*(to-from))+"px"; if( step == 1) clearInterval(timer); },20); //Expand List ul.style.overflow = "inherit"; ul.style.height = "auto"; ul.style.visibility = "inherit"; </code></pre> <p><code>ul</code> in the code is reference to the <code>ul</code> elements in unordered list currently being expanded.</p> <p>But after using this code to animate expand behavior, width of outer <code>ul</code> element is not changing with expand of inner <code>ul</code> element. However animation is working fine, but list is looking like this:</p> <p><img src="https://i.stack.imgur.com/DFohv.jpg" alt="Incorrectly displayed unordered list"> </p> <p>When I comment out <code>//ul.style.height = (from+step*(to-from))+"px";</code> from <code>setInterval</code>, list is being displayed correctly (however no animation effect). </p> <p>Can you please point out error, why is not width of outer <code>ul</code> changing with expand of inner <code>ul</code></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.
 

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