Skip to content

Commit c064c8b

Browse files
committed
tag 1.0.2 fix style and add undefine judge
1 parent b36fd7b commit c064c8b

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuepress-plugin-demo-block-vue3",
3-
"version": "1.0.0",
3+
"version": "1.0.2",
44
"description": "Vuepress2 plugin for demo block support vue3.",
55
"main": "src/index.js",
66
"scripts": {

src/DemoBlock.vue

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default {
109109
this.$el.getElementsByClassName("code-content")[0].clientHeight +
110110
30
111111
);
112-
}
112+
}
113113
return this.$el.getElementsByClassName("code-content")[0].clientHeight + 20;
114114
}
115115
},
@@ -129,11 +129,15 @@ export default {
129129
}, 1500);
130130
},
131131
scrollHandler() {
132-
const { top, bottom, left } = this.$refs.meta.getBoundingClientRect();
133-
this.fixedControl =
134-
bottom > document.documentElement.clientHeight &&
135-
top + 44 <= document.documentElement.clientHeight;
136-
this.$refs.control.style.left = this.fixedControl ? `${left + 1}px` : "0";
132+
this.$nextTick(() => {
133+
if (this.$refs && this.$refs.meta && this.$refs.meta.getBoundingClientRect) {
134+
const { top, bottom, left } = this.$refs.meta.getBoundingClientRect();
135+
this.fixedControl =
136+
bottom > document.documentElement.clientHeight &&
137+
top + 44 <= document.documentElement.clientHeight;
138+
this.$refs.control.style.left = this.fixedControl ? `${left + 1}px` : "0";
139+
}
140+
})
137141
},
138142
removeScrollHandler() {
139143
this.scrollParent &&
@@ -245,7 +249,7 @@ export default {
245249
-webkit-font-smoothing: antialiased;
246250
}
247251
.demo-block .demo-block-control .caret-top::before {
248-
margin-top: 2px;
252+
margin-top: 6px;
249253
content: "";
250254
position: absolute;
251255
right: 50%;
@@ -256,7 +260,7 @@ export default {
256260
border-left: 6px solid transparent;
257261
}
258262
.demo-block .demo-block-control .caret-bottom::before {
259-
margin-top: 2px;
263+
margin-top: 6px;
260264
content: "";
261265
position: absolute;
262266
right: 50%;

0 commit comments

Comments
 (0)