【问题标题】:How can I implement animate on page scroll?如何在页面滚动上实现动画?
【发布时间】:2017-02-27 14:50:31
【问题描述】:

当用户滚动浏览网页时,如何触发动画 css?

是v-show="element"出现时触发x的问题吗?

使用 Vue 2 + 动画 css

【问题讨论】:

    标签: vuejs2 animate.css


    【解决方案1】:

    我发现 Ikbel 的回答很有用

    How to display and transition when scroll position reaches element position in the screen?

    您可以使用自定义指令来实现这一点,该指令将窗口滚动事件的 inViewport 绑定添加到您想要动画的元素。

    我将数据转换添加到要制作动画的 html 元素中

    <div v-vpshow data-transition="flipInX"><div>
    

    并像这样更改绑定

    el.$onScroll = function() {
        if (binding.def.inViewport(el)) {
            el.classList.add('animated')
            el.classList.add(el.getAttribute('data-transition'))
            el.classList.remove('before-enter')
            binding.def.unbind(el, binding)
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2020-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-11
      • 2022-07-08
      相关资源
      最近更新 更多