@@ -190,16 +190,19 @@ class QAController {
190190 this . qaBox ,
191191 this . fragmentBox ,
192192 this . backpackBox ,
193- this . puzzleBox ,
194- this . backEntry
193+ this . puzzleBox
195194 ] , [ this . initInfo , this . startContent ] ) ;
196195
196+ // 初始时隐藏背包入口
197+ this . hideBackEntry ( ) ;
198+
197199 if ( this . startBtn ) {
198200 this . startBtn . addEventListener ( "click" , ( ) => {
199201 this . showHideController ( [
200202 this . initInfo ,
201203 this . startContent
202- ] , [ this . levelInfo , this . qaBox , this . backEntry ] ) ;
204+ ] , [ this . levelInfo , this . qaBox ] ) ;
205+ this . showBackEntry ( ) ;
203206 this . updateHeader ( ) ;
204207 this . showQuestion ( ) ;
205208 } ) ;
@@ -365,7 +368,6 @@ class QAController {
365368 this . qaBox ,
366369 this . levelInfo ,
367370 this . fragmentBox ,
368- this . backEntry ,
369371 this . backpackBox
370372 ] , [ this . puzzleBox ] ) ;
371373 this . renderPuzzle ( ) ;
@@ -390,8 +392,7 @@ class QAController {
390392 const level = this . getCurrentLevel ( ) ;
391393 this . showHideController ( [
392394 this . qaBox ,
393- this . levelInfo ,
394- this . backEntry
395+ this . levelInfo
395396 ] , [ this . fragmentBox ] ) ;
396397 if ( this . fragmentImgElem ) this . fragmentImgElem . src = level . reward ;
397398 const totalLevels = this . data . length ;
@@ -406,7 +407,7 @@ class QAController {
406407 this . selectedOptionId = null ;
407408 this . showHideController ( [
408409 this . fragmentBox
409- ] , [ this . levelInfo , this . qaBox , this . backEntry ] ) ;
410+ ] , [ this . levelInfo , this . qaBox ] ) ;
410411 this . updateHeader ( ) ;
411412 this . showQuestion ( ) ;
412413 } else {
@@ -415,7 +416,7 @@ class QAController {
415416 this . fragmentBox ,
416417 this . levelInfo ,
417418 this . qaBox
418- ] , [ this . backEntry , this . backpackBox ] ) ;
419+ ] , [ this . backpackBox ] ) ;
419420 this . renderBackpack ( ) ;
420421 }
421422 }
@@ -455,7 +456,7 @@ class QAController {
455456 this . levelInfo ,
456457 this . qaBox ,
457458 this . fragmentBox ,
458- this . backEntry
459+ this . backpackBox
459460 ] , [ this . puzzleBox ] ) ;
460461 this . renderPuzzle ( ) ;
461462 }
@@ -467,7 +468,7 @@ class QAController {
467468 } else {
468469 this . showHideController ( [
469470 this . backpackBox
470- ] , [ this . levelInfo , this . qaBox , this . backEntry ] ) ;
471+ ] , [ this . levelInfo , this . qaBox ] ) ;
471472 this . updateHeader ( ) ;
472473 this . showQuestion ( ) ;
473474 }
@@ -619,23 +620,42 @@ class QAController {
619620 }
620621 }
621622
623+ showBackEntry ( ) {
624+ if ( this . backEntry ) {
625+ this . backEntry . style . display = 'flex' ;
626+ this . backEntry . style . opacity = '1' ;
627+ }
628+ }
629+
630+ hideBackEntry ( ) {
631+ if ( this . backEntry ) {
632+ this . backEntry . style . display = 'none' ;
633+ this . backEntry . style . opacity = '0' ;
634+ }
635+ }
636+
622637 showHideController ( hiddenControllers , showControllers ) {
638+ // 立即隐藏不需要的元素
623639 hiddenControllers . forEach ( controller => {
624640 if ( controller ) {
641+ controller . style . display = 'none' ;
625642 controller . style . opacity = '0' ;
626- setTimeout ( ( ) => {
627- controller . style . display = 'none' ;
628- } , 300 ) ;
629643 }
630644 } ) ;
631- setTimeout ( ( ) => {
632- showControllers . forEach ( controller => {
633- if ( controller ) {
645+
646+ // 立即显示需要的元素,然后添加渐入效果
647+ showControllers . forEach ( controller => {
648+ if ( controller ) {
649+ controller . style . display = 'flex' ;
650+ controller . style . opacity = '0' ;
651+ // 强制重排,确保display变化生效
652+ controller . offsetHeight ;
653+ // 添加渐入效果
654+ setTimeout ( ( ) => {
634655 controller . style . opacity = '1' ;
635- controller . style . display = 'flex' ;
636- }
637- } ) ;
638- } , 300 ) ;
656+ } , 50 ) ;
657+ }
658+ } ) ;
639659 }
640660}
641661
0 commit comments