|
@@ -1,4 +1,4 @@
|
|
-import { defineComponent, computed, reactive, onMounted } from 'vue';
|
|
|
|
|
|
+import { defineComponent, computed, reactive, onMounted, nextTick } from 'vue';
|
|
import styles from './index.module.less';
|
|
import styles from './index.module.less';
|
|
// 底部拖动区域
|
|
// 底部拖动区域
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
@@ -13,17 +13,31 @@ export default defineComponent({
|
|
},
|
|
},
|
|
setup(props, { emit }) {
|
|
setup(props, { emit }) {
|
|
const data = reactive({
|
|
const data = reactive({
|
|
- guidePos: "bottom" as "bottom" | "top",
|
|
|
|
|
|
+ guidePos: "bottom" as "bottom" | "left" | "right",
|
|
});
|
|
});
|
|
|
|
|
|
const initGuidePos = () => {
|
|
const initGuidePos = () => {
|
|
const pageHeight = document.documentElement.clientHeight || document.body.clientHeight;
|
|
const pageHeight = document.documentElement.clientHeight || document.body.clientHeight;
|
|
- const guideHeight = document.querySelector('.bom_guide')?.getBoundingClientRect().height || 0;
|
|
|
|
- const dragTop = document.querySelector('.bom_drag')?.getBoundingClientRect()?.top || 0;
|
|
|
|
- data.guidePos = pageHeight - dragTop < guideHeight ? "top" : "bottom";
|
|
|
|
|
|
+ const pageWidth = document.documentElement.clientWidth || document.body.clientWidth;
|
|
|
|
+ const guideHeight = document.querySelector('.bom_guide')?.clientHeight || 0;
|
|
|
|
+ const guideWidth = document.querySelector('.bom_guide')?.clientWidth || 0;
|
|
|
|
+ const dragBBox = document.querySelector('.bom_drag')?.getBoundingClientRect();
|
|
|
|
+ const dragTop = dragBBox?.top || 0;
|
|
|
|
+ const dragLeft = dragBBox?.left || 0;
|
|
|
|
+ // 引导页出现在下边
|
|
|
|
+ if (pageHeight - dragTop > guideHeight) {
|
|
|
|
+ data.guidePos = "bottom"
|
|
|
|
+ } else {
|
|
|
|
+ // 引导页出现在左边or右边
|
|
|
|
+ data.guidePos = dragLeft > guideWidth ? "left" : "right"
|
|
|
|
+ }
|
|
}
|
|
}
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
- initGuidePos();
|
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ initGuidePos();
|
|
|
|
+ }, 0);
|
|
|
|
+ });
|
|
});
|
|
});
|
|
return () => (
|
|
return () => (
|
|
<>
|
|
<>
|
|
@@ -33,7 +47,7 @@ export default defineComponent({
|
|
</div>
|
|
</div>
|
|
{
|
|
{
|
|
props.showGuide &&
|
|
props.showGuide &&
|
|
- <div class={[styles.guide, data.guidePos === "top" && styles.guideTop, 'bom_guide']} onClick={() => emit("guideDone")}>
|
|
|
|
|
|
+ <div class={[styles.guide, data.guidePos === "left" && styles.guideLeft, data.guidePos === "right" && styles.guideRight, 'bom_guide']} onClick={() => emit("guideDone")}>
|
|
<div class={styles.guideBg}></div>
|
|
<div class={styles.guideBg}></div>
|
|
<div class={styles.guideDone}></div>
|
|
<div class={styles.guideDone}></div>
|
|
</div>
|
|
</div>
|