natasha 2 months ago
parent
commit
ca0c05f20b

+ 13 - 3
src/views/book/courseware/preview/components/h5_games/H5GamesPreview.vue

@@ -62,6 +62,12 @@ export default {
     document.addEventListener('keyup', (e) => {
       if (event.key === 'Escape' || event.key === 'Esc' || event.keyCode === 27) {
         this.full_type = false;
+        this.$nextTick(() => {
+          const div = document.querySelector('.main-container');
+          if (div) {
+            div.scrollTop = this.scroll_top;
+          }
+        });
       }
     });
   },
@@ -82,13 +88,17 @@ export default {
       const div = document.querySelector('.main-container');
       if (div) {
         if (this.full_type) {
-          div.scrollTop = this.scroll_top;
+          this.full_type = false;
+          this.$nextTick(() => {
+            div.scrollTop = this.scroll_top;
+          });
         } else {
           this.scroll_top = div.scrollTop;
+          this.full_type = true;
         }
+      } else {
+        this.full_type = !this.full_type;
       }
-
-      this.full_type = !this.full_type;
     },
     /**
      * 获取无文本内容的数据结构,用于保存为个人模板时的样式模板