2.0.1版的Velocity Scroll问题 [英] Velocity Scroll Issue with Version 2.0.1

查看:123
本文介绍了2.0.1版的Velocity Scroll问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对Velocity的最新版本(2.0.1)的更新导致与滚动有关的问题.具体来说,将引发以下错误消息:

An update to the newest version of Velocity (2.0.1) causes an issue related to scroll. Specifically, the following error message is thrown:

错误:速度:第一个参数(滚动)不是属性映射,已知操作或注册的重定向.正在中止.

Error: Velocity: First argument (scroll) was not a property map, a known action, or a registered redirect. Aborting.

以下示例在Velocity 1.5上运行良好: https://codepen.io/julianshapiro/pen/kBuEi

The following example works fine with Velocity 1.5: https://codepen.io/julianshapiro/pen/kBuEi

由于SO需要代码,因此这是CodePen中的相关部分:

Since SO requires code, here is the relevant portion from the CodePen:

$("#element3").velocity("scroll", { 
  container: $("#container"),
  duration: 800,
  delay: 500
});

但是,当改用Velocity 2.0.1时,它会引发错误: https://codepen .io/anon/pen/QQgOPx

However, when Velocity 2.0.1 is used instead, it throws the error: https://codepen.io/anon/pen/QQgOPx

有人可以告诉我如何解决此问题吗?

Can someone tell me how to fix this?

推荐答案

Velocity V2的编码器,然后指向

Coder of Velocity V2 here, and going to point at the V2 Changes file:

当前已禁用/未更新:

  • 滚动(有效,但对界面不满意-如果人们想玩,这是一个属性,scrollTop的别名,还有scrollLeft)

Currently disabled / not updated:

  • Scroll (working, but not happy with interface - it's a property if people want to play, alias of scrollTop, there's also scrollLeft)

就这样了,但是我很可能会更改基础代码(如果/在发生这种情况时,接口将保持相同),但是现在进行动画处理是正常的属性(并且将保持不变)-因此,现在使用它,您将执行以下操作:

So it's in, but I'm likely to change the underlying code (the interface will remain identical if/when that happens though), it is however a normal property to animate now (and will stay as such) - so to use it now you'd do something like:

$("#container").velocity({scrollTop: "500px"}, {
  duration: 800,
  delay: 500
});

如果要向下滚动到另一个元素,则需要找到该元素与第一个元素的相对位置(这应该是一个单独的问题,但是完成后我会添加到Wiki中).

If you want to scroll down to another element, then you'd need to find the relative position of that element compared to the first (which should be a separate issue, but I will add to the wiki when it's done).

注意:我鼓励人们使用"scrollTop"而不是"scroll",以明显表明您没有使用"scrollLeft".

Note: I'd encourage people to use "scrollTop" instead of "scroll" to make it obvious that you're not using "scrollLeft".

注意2:"scrollTop"在2.0.1中,其他的将在下一个beta 2.0.2中-但现在在回购中.

Note2: "scrollTop" is in 2.0.1, the other ones will be in the next beta 2.0.2 - but are in the repo right now.

这篇关于2.0.1版的Velocity Scroll问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆