4

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.

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

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

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

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?

bryman79
  • 373
  • 1
  • 11
  • 1
    why the downvote? – bryman79 Feb 13 '18 at 01:00
  • Just in case people are only reading the question - this is where it's worth reading the Changelog (or in this case the V2_CHANGES.md file) - the API for scrolling has changed to be consistent within Velocity, as a normal animation property :-) – Rycochet Feb 18 '18 at 00:07

2 Answers2

2

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

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
});

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).

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

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.

Rycochet
  • 2,690
  • 1
  • 19
  • 35
1

It appears that scroll action is available in v1.5.0 (Line: 3161) but appears to be missing from v2.0

Varinder
  • 2,564
  • 1
  • 14
  • 19
  • Actually it's in V2 as a normalisation, the code has changed completely and it's not something you can simply compare the V2 final output file to the V1 source file to see. – Rycochet Feb 18 '18 at 00:10