@@ -285,14 +285,20 @@ function traverseForPaths () {
285285 *
286286 * @param $expandElem expander
287287 * @param callback callback function
288+ * @param skipTreeAnimation skip tree opening animation when true
288289 */
289- function expandTreeNode ( $expandElem , callback = undefined ) : void {
290+ function expandTreeNode ( $expandElem , callback = undefined , skipTreeAnimation = false ) : void {
290291 let $children = $expandElem . closest ( 'li' ) . children ( 'div.list_container' ) ;
291292 const $icon = $expandElem . find ( 'img' ) ;
292293 if ( $expandElem . hasClass ( 'loaded' ) ) {
293294 if ( $icon . is ( '.ic_b_plus' ) ) {
294295 $icon . removeClass ( 'ic_b_plus' ) . addClass ( 'ic_b_minus' ) ;
295- $children . slideDown ( 'fast' ) ;
296+ // check whether to show tree immediately or play animation
297+ if ( skipTreeAnimation ) {
298+ $children . show ( ) ;
299+ } else {
300+ $children . slideDown ( 'fast' ) ;
301+ }
296302 }
297303
298304 if ( callback && typeof callback === 'function' ) {
@@ -314,7 +320,13 @@ function expandTreeNode ($expandElem, callback = undefined): void {
314320 const $destination = $expandElem . closest ( 'li' ) ;
315321 $icon . removeClass ( 'ic_b_plus' ) . addClass ( 'ic_b_minus' ) ;
316322 $children = $destination . children ( 'div.list_container' ) ;
317- $children . slideDown ( 'fast' ) ;
323+ // check whether to show tree immediately or play animation
324+ if ( skipTreeAnimation ) {
325+ $children . show ( ) ;
326+ } else {
327+ $children . slideDown ( 'fast' ) ;
328+ }
329+
318330 if ( $destination . find ( 'ul > li' ) . length === 1 ) {
319331 $destination . find ( 'ul > li' )
320332 . find ( 'a.expander.container' )
@@ -365,8 +377,10 @@ function scrollToView ($element, $forceToTop) {
365377
366378/**
367379 * Expand the navigation and highlight the current database or table/view
380+ *
381+ * @param {boolean } skipTreeAnimation skip tree opening animation when true (passed down into expandTreeNode from fullExpand)
368382 */
369- function showCurrent ( ) : void {
383+ function showCurrent ( skipTreeAnimation = false ) : void {
370384 const db = CommonParams . get ( 'db' ) ;
371385 const table = CommonParams . get ( 'table' ) ;
372386
@@ -402,7 +416,7 @@ function showCurrent (): void {
402416 handleTableOrDb ( table , $ ( '#pma_navigation_tree_content' ) ) ;
403417 }
404418 } else if ( $dbItem ) {
405- fullExpand ( table , $dbItem ) ;
419+ fullExpand ( table , $dbItem , skipTreeAnimation ) ;
406420 }
407421 } else if ( $ ( '#navi_db_select' ) . length && $ ( '#navi_db_select' ) . val ( ) ) {
408422 $ ( '#navi_db_select' ) . val ( '' ) . hide ( ) . trigger ( 'change' ) ;
@@ -423,20 +437,20 @@ function showCurrent (): void {
423437 $ ( '#pma_navigation_tree' ) . find ( '> div' ) , dbItemName , 'database' , ! table
424438 ) ;
425439
426- fullExpand ( table , $dbItem ) ;
440+ fullExpand ( table , $dbItem , skipTreeAnimation ) ;
427441 }
428442
429443 Navigation . showFullName ( $ ( '#pma_navigation_tree' ) ) ;
430444
431- function fullExpand ( table , $dbItem ) {
445+ function fullExpand ( table , $dbItem , skipTreeAnimation ) {
432446 const $expander = $dbItem . children ( 'div' ) . first ( ) . children ( 'a.expander' ) ;
433447 // if not loaded or loaded but collapsed
434448 if ( ! $expander . hasClass ( 'loaded' ) ||
435449 $expander . find ( 'img' ) . is ( '.ic_b_plus' )
436450 ) {
437451 Navigation . expandTreeNode ( $expander , function ( ) {
438452 handleTableOrDb ( table , $dbItem ) ;
439- } ) ;
453+ } , skipTreeAnimation ) ;
440454 } else {
441455 handleTableOrDb ( table , $dbItem ) ;
442456 }
@@ -655,7 +669,7 @@ function reload (callback = null, paths = null): void {
655669 $ ( '#pma_navigation_tree' ) . html ( data . message ) . children ( 'div' ) . show ( ) ;
656670 if ( $ ( '#pma_navigation_tree' ) . hasClass ( 'synced' ) ) {
657671 Navigation . selectCurrentDatabase ( ) ;
658- Navigation . showCurrent ( ) ;
672+ Navigation . showCurrent ( paths !== null ) ; // skip tree opening animation when there is tree state in sessionStorage
659673 }
660674
661675 // Fire the callback, if any
0 commit comments