@@ -1424,11 +1424,13 @@ <h2 class="section-title reveal" data-en="Join the Community" data-zh="加入社
14241424 }
14251425} ) ( ) ;
14261426
1427- /* Lock serial panel height after layout settles to prevent content growth */
1427+ /* Lock serial panel height to prevent content growth */
1428+ var serialPanelSavedHeight = 0 ;
14281429window . addEventListener ( 'load' , function ( ) {
14291430 var sp = document . querySelector ( '.serial-panel' ) ;
1430- if ( sp && ! sp . classList . contains ( 'expanded' ) ) {
1431- sp . style . height = sp . offsetHeight + 'px' ;
1431+ if ( sp ) {
1432+ serialPanelSavedHeight = sp . offsetHeight ;
1433+ sp . style . height = serialPanelSavedHeight + 'px' ;
14321434 }
14331435} ) ;
14341436
@@ -1763,15 +1765,18 @@ <h2 class="section-title reveal" data-en="Join the Community" data-zh="加入社
17631765function serialExpand ( ) {
17641766 var panel = document . querySelector ( '.serial-panel' ) ;
17651767 var btn = document . getElementById ( 'serial-expand-btn' ) ;
1766- var wasExpanded = panel . classList . contains ( 'expanded' ) ;
1767- panel . style . height = '' ;
1768- panel . classList . toggle ( 'expanded' ) ;
1769- btn . classList . toggle ( 'active' , ! wasExpanded ) ;
1770- if ( wasExpanded ) {
1771- /* Collapsing: wait for layout reflow then lock height */
1772- requestAnimationFrame ( function ( ) {
1773- panel . style . height = panel . offsetHeight + 'px' ;
1774- } ) ;
1768+ var isExpanded = panel . classList . contains ( 'expanded' ) ;
1769+ if ( ! isExpanded ) {
1770+ /* About to expand: save current height */
1771+ serialPanelSavedHeight = panel . offsetHeight ;
1772+ panel . style . height = '' ;
1773+ panel . classList . add ( 'expanded' ) ;
1774+ btn . classList . add ( 'active' ) ;
1775+ } else {
1776+ /* Collapse: restore saved height */
1777+ panel . classList . remove ( 'expanded' ) ;
1778+ btn . classList . remove ( 'active' ) ;
1779+ panel . style . height = serialPanelSavedHeight + 'px' ;
17751780 }
17761781}
17771782</ script >
0 commit comments