- 持续滚动
<template>
<div class="game-module-bg animate">
<img src="@/assets/images/bg-2.jpg" class="img" />
<img src="@/assets/images/bg-2.jpg" class="img" />
</div>
</template>
<script>
export default {
methods: {
gameAnimateFn() {
let el = document.querySelector(".img");
let H = document.body.clientHeight;
let parentEl = document.querySelector(".animate");
let initData = parseFloat(el.style.marginTop) || 0;
let p = initData - 200;
if (1000 > parentEl.scrollHeight + p) {
let newImgEl = document.createElement("img");
newImgEl.setAttribute("src", require("@/assets/images/bg-2.jpg"));
parentEl.appendChild(newImgEl);
}
el.style.marginTop = p + "px";
},
}
}
</script>