|
@@ -55,40 +55,54 @@ const mousemoveFu = (e, flag) => {
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
- // 判断画轴有没有超过屏幕
|
|
|
- const pageHeightWindow = window.innerHeight
|
|
|
- pageHeight.value = pageHeightWindow
|
|
|
+ const element = document.querySelector('#myElement')
|
|
|
|
|
|
+ const resizeObserver = new ResizeObserver(entries => {
|
|
|
+ for (let entry of entries) {
|
|
|
+ console.log(`Width changed to ${entry.contentRect.width}`)
|
|
|
+ // 在这里执行你的逻辑
|
|
|
+ // 判断画轴有没有超过屏幕
|
|
|
+ const pageHeightWindow = window.innerHeight
|
|
|
+ pageHeight.value = pageHeightWindow
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
- if (isRow.value === "竖") {
|
|
|
- const dom = document.querySelector(".imgBox")
|
|
|
- if (dom.offsetHeight > pageHeightWindow) {
|
|
|
- isMove.value = true
|
|
|
- imgWidth.value = dom.offsetWidth
|
|
|
- imgHeight.value = dom.offsetHeight
|
|
|
- }
|
|
|
- } else {
|
|
|
- const leftBoxWidthDom = document.querySelector(".leftBxo")
|
|
|
- const leftBoxWidthDomWidth = leftBoxWidthDom.offsetWidth
|
|
|
- leftBoxWidth.value = leftBoxWidthDomWidth
|
|
|
- const dom = document.querySelector(".imgBoxHH")
|
|
|
- if (dom.offsetWidth > leftBoxWidthDomWidth) {
|
|
|
- isMove.value = true
|
|
|
- imgWidth.value = dom.offsetWidth
|
|
|
- imgHeight.value = dom.offsetHeight
|
|
|
- }
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ if (isRow.value === "竖") {
|
|
|
+ const dom = document.querySelector(".imgBox")
|
|
|
+ if (dom.offsetHeight > pageHeightWindow) {
|
|
|
+ isMove.value = true
|
|
|
+ imgWidth.value = dom.offsetWidth
|
|
|
+ imgHeight.value = dom.offsetHeight
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const leftBoxWidthDom = document.querySelector(".leftBxo")
|
|
|
+ const leftBoxWidthDomWidth = leftBoxWidthDom.offsetWidth
|
|
|
+ leftBoxWidth.value = leftBoxWidthDomWidth
|
|
|
+ const dom = document.querySelector(".imgBoxHH")
|
|
|
+ if (dom.offsetWidth > leftBoxWidthDomWidth) {
|
|
|
+ isMove.value = true
|
|
|
+ imgWidth.value = dom.offsetWidth
|
|
|
+ imgHeight.value = dom.offsetHeight
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 200)
|
|
|
+ tiemrr.value = setInterval(() => {
|
|
|
+ if (zhouMove.value >= 99) clearInterval(tiemrr.value)
|
|
|
+ zhouMove.value = zhouMove.value + 1
|
|
|
+ }, 30)
|
|
|
}
|
|
|
- }, 200)
|
|
|
- tiemrr.value = setInterval(() => {
|
|
|
- if (zhouMove.value >= 99) clearInterval(tiemrr.value)
|
|
|
- zhouMove.value = zhouMove.value + 1
|
|
|
- }, 30)
|
|
|
+ })
|
|
|
+
|
|
|
+ resizeObserver.observe(element)
|
|
|
+
|
|
|
})
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <div class="box">
|
|
|
+ <div
|
|
|
+ id="myElement"
|
|
|
+ class="box"
|
|
|
+ >
|
|
|
<div
|
|
|
:class="`leftBxo ${isMove ? '' : isRow === '横' ? '' : 'leftBxoCenter'}`"
|
|
|
>
|
|
@@ -221,8 +235,8 @@ onMounted(() => {
|
|
|
justify-content: center;
|
|
|
}
|
|
|
.box {
|
|
|
- width: 100vw;
|
|
|
- height: 100vh;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
overflow: hidden;
|
|
|
.leftBxo {
|
|
|
// background-color: aquamarine;
|