Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Velocity mutating options object w/ sequences #265

Closed
fattenap opened this issue Aug 24, 2014 · 4 comments
Closed

Velocity mutating options object w/ sequences #265

fattenap opened this issue Aug 24, 2014 · 4 comments
Labels

Comments

@fattenap
Copy link

I store animation options in an array. For example var optionsArray = [{stagger: 75, drag: true}]. I then pass optionsArray[0] to Velocity as the options argument.

Velocity("transition.slideUpIn", optionsArray[0]);

This passes in optionsArray[0] as a reference to Velocity. Velocity then adds a delay property to the passed in options object, effectively mutating my options object. Now optionsArray[0] looks like this => {delay:875, stagger:75, drag: true;}

The next time I call Velocity("transition.slideUpIn", optionsArray[0]); it passes in {delay:875, stagger:75, drag: true;} which delays the animation. This compounds for each subsequent call as delay gets longer and longer.

Here's a CodePen showing the issue http://codepen.io/fattenap/pen/IglzH

Would it be possible for Velocity to take a copy of passed in options if it intends on mutating it. This way my object won't be affected.

Thanks

@ydaniv
Copy link
Contributor

ydaniv commented Aug 24, 2014

@fattenap yep, that's indeed a problem.

@julianshapiro probably means wrapping all arguments[..] references in animate() with something like $.extend({}, ...).

@fattenap fattenap changed the title transitions taking longer to start for each subsequent animation when using the stagger option options mutating object Aug 24, 2014
@fattenap fattenap changed the title options mutating object Velocity mutating options object Aug 24, 2014
@julianshapiro
Copy link
Owner

Agreed. The fix is simple. Expect this in the next update. Thanks, guys.

@julianshapiro julianshapiro changed the title Velocity mutating options object Velocity mutating options object w/ sequences Aug 24, 2014
@julianshapiro
Copy link
Owner

Done. Please test, confirm it works, and get back to me. Thank you so much!

@fattenap
Copy link
Author

Tested and it works.

Thanks!

Rycochet pushed a commit that referenced this issue Aug 3, 2020
Apply `overflow: hidden` when using the slide commands. Closes #260.

Sequence (UI pack effect) options object no longer gets externally
modified by Velocity. Closes #265.

Fixed bug where tweens would jump when dequeuing custom queues. Closes
#262. (The reverse command now only applies to the default effects
queue; reverse cannot be used with custom queues or parallel queueing
(queue: false).)

Fixed unit conversion bug on the `x` property of SVG elements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants