【发布时间】:2019-11-11 01:12:57
【问题描述】:
我想通过点击Previous Page 和Next Page 按钮,使用Animate Plus,按视口的整个宽度平滑地为页面部分的水平滚动设置动画。
以下是相关代码:
import animate from "https://cdn.jsdelivr.net/npm/animateplus@2/animateplus.js"
const previousPage = document.querySelector("button:nth-of-type(1)")
const nextPage = document.querySelector("button:nth-of-type(2)")
previousPage.addEventListener("click", () => {
window.scrollBy(-window.innerWidth, 0)
animate({
easing: "out-quintic"
})
})
nextPage.addEventListener("click", () => {
window.scrollBy(window.innerWidth, 0)
animate({
easing: "out-quintic"
})
})
我的完整代码可以在这里找到:
我想实现的动画效果可以在这里找到:
我错过了什么?
【问题讨论】:
标签: javascript animation ecmascript-6 scroll animateplus