File tree Expand file tree Collapse file tree 4 files changed +57
-6
lines changed Expand file tree Collapse file tree 4 files changed +57
-6
lines changed Original file line number Diff line number Diff line change 2020 "nprogress" : " ^0.2.0" ,
2121 "regenerator-runtime" : " ^0.13.7" ,
2222 "theme-switcher-tool" : " ^1.0.3" ,
23+ "vue-lazy-container" : " ^1.1.1" ,
2324 "vue-router" : " ^3.2.0" ,
2425 "vue-template-compiler" : " ^2.6.11"
2526 },
Original file line number Diff line number Diff line change 55 @mouseenter =" hovering = true"
66 @mouseleave =" hovering = false"
77 >
8- <div class =" source" >
9- <slot name =" source" ></slot >
10- </div >
8+ <vue-lazy-container
9+ class =" source-code-container"
10+ tag-name =" div"
11+ @change =" visibilityChange"
12+ >
13+ <div v-if =" isDemoRendered" class =" source" >
14+ <slot name =" source" ></slot >
15+ </div >
16+ <div v-else class =" source-empty" >
17+ Loading...
18+ </div >
19+ </vue-lazy-container >
1120 <div v-if =" $slots.default" class =" description" >
1221 <div class =" title-container" >
1322 <span class =" title" > {{ demoLangInfo.description }}</span >
@@ -89,7 +98,9 @@ export default {
8998 hovering: false ,
9099 isExpanded: false ,
91100 fixedControl: false ,
92- scrollParent: null
101+ scrollParent: null ,
102+ // 是否示例渲染完成
103+ isDemoRendered: false
93104 };
94105 },
95106
@@ -154,6 +165,16 @@ export default {
154165 },
155166
156167 methods: {
168+ // visibility change
169+ visibilityChange (entry , observer , id ) {
170+ const { isIntersecting } = entry;
171+
172+ // visibility
173+ if (isIntersecting) {
174+ this .isDemoRendered = true ;
175+ }
176+ },
177+ // scroll handler
157178 scrollHandler () {
158179 const {
159180 top ,
@@ -237,8 +258,20 @@ export default {
237258 float : right ;
238259 }
239260
240- .source {
241- padding : 24px ;
261+ .source-code-container {
262+ min-height : 250px ;
263+ .source {
264+ padding : 24px ;
265+ }
266+ .source-empty {
267+ min-height : 250px ;
268+ width : 100% ;
269+ height : 100% ;
270+ display : flex ;
271+ justify-content : center ;
272+ align-items : center ;
273+ color : #666 ;
274+ }
242275 }
243276
244277 .description {
Original file line number Diff line number Diff line change @@ -23,11 +23,16 @@ import Anchor from "@/comp/anchor.vue";
2323Vue . component ( "demo-block" , DemoBlock ) ;
2424Vue . component ( "anchor" , Anchor ) ;
2525
26+ // 仅用作示例
2627import { Switch , Row , Col } from "element-ui" ;
2728Vue . use ( Switch ) ;
2829Vue . use ( Row ) ;
2930Vue . use ( Col ) ;
3031
32+ // vue-lazy-container
33+ import VueLazyContainer from "vue-lazy-container" ;
34+ Vue . use ( VueLazyContainer ) ;
35+
3136// product
3237/* import "../../libs/theme-default/index.css";
3338import {
Original file line number Diff line number Diff line change @@ -5802,6 +5802,11 @@ interpret@^1.2.0:
58025802 resolved "https://registry.npm.taobao.org/interpret/download/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e"
58035803 integrity sha1-Zlq4vE2iendKQFhOgS4+D6RbGh4=
58045804
5805+ intersection-observer@^0.12.0:
5806+ version "0.12.0"
5807+ resolved "https://registry.yarnpkg.com/intersection-observer/-/intersection-observer-0.12.0.tgz#6c84628f67ce8698e5f9ccf857d97718745837aa"
5808+ integrity sha512-2Vkz8z46Dv401zTWudDGwO7KiGHNDkMv417T5ItcNYfmvHR/1qCTVBO9vwH8zZmQ0WkA/1ARwpysR9bsnop4NQ==
5809+
58055810invariant@^2.2.2, invariant@^2.2.4:
58065811 version "2.2.4"
58075812 resolved "https://registry.npm.taobao.org/invariant/download/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
@@ -11023,6 +11028,13 @@ vue-jest@^3.0.5:
1102311028 tsconfig "^7.0.0"
1102411029 vue-template-es2015-compiler "^1.6.0"
1102511030
11031+ vue-lazy-container@^1.1.1:
11032+ version "1.1.1"
11033+ resolved "https://registry.yarnpkg.com/vue-lazy-container/-/vue-lazy-container-1.1.1.tgz#40721df4f15e7967c17d4385ecf23433eeca594a"
11034+ integrity sha512-tpE0lafi+tPlVyzAvuouYI+dmZ3xbsSWMuRI0FhawVN5gAvwTjgBxNL7m/VsMZ4arfDGBa3NwR63aE36vz1qyA==
11035+ dependencies:
11036+ intersection-observer "^0.12.0"
11037+
1102611038vue-loader@^15.9.2:
1102711039 version "15.9.7"
1102811040 resolved "https://registry.nlark.com/vue-loader/download/vue-loader-15.9.7.tgz#15b05775c3e0c38407679393c2ce6df673b01044"
You can’t perform that action at this time.
0 commit comments