-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
UI Pack: Option to skip property resetting #132
Conversation
Hey Ross, First off, your implementation is almost perfect -- only tweak is that it can be shortened slightly. Second, I'm intrigued by your proposal, but I unfortunately do not understand the problem you're solving. Could you please elucidate and/or create a JSFiddle example for me to play with? Thank you so much. Super appreciated. |
Hey Julian, I've made a plnkr that demonstrates the issue: http://plnkr.co/edit/Rr85oTDPspLLPDEhV4UE?p=preview You can see that as you click the toggle button, the DOM begins to leak and get duplicated, when there should only ever be 1 element present depending on the condition of the isShowing boolean. |
Skipping animation resets are also desirable if there is already an animation running, and you (likely) want to continue from where you are presently in the current-previous animation. |
Hey Julian, Took a deep look into this just now. It appears to be a timing issue with the complete callback. I've done a small refactor (+rebased to newest release) to how the complete callback is defined that avoids needing to wrap it in an outer function definition and then use This seems like a win-win to me -- no more Thoughts? Edit: Just noticed the changes I've made will run the reset effect too early, rather than after the last animation call is done...hmm. |
Having just read that you're planning on releasing some major updates over the coming days/weeks, I'm going to close those for now. Appreciate the help so far. |
Please try working with the updated UI pack. (Just pushed.) Let me know how this issue concludes. I'd love to talk further about publicizing this plugin. Thanks a bunch, @rosslavery. |
Hey Julian, Still no dice. The issue only occurs when I run the "opposite" animation of the one that helped it enter the DOM. Angular's animation system requires that you pass in an animation to run for when a specified DOM element is added, moved (re-ordered), and removed. What this means is that if someone chooses to use a Regardless of this, it doesn't seem to matter since both of those Another solution I can think of to avoid adding the questionable skipReset option would be to expose the default UI pack animations ( At the moment they are a private variable inside of the UI pack, but if they were exposed for the user to modify and extend, it would allow me to iterate through the defaults, remove the reset property for my use-case, and register them with the new This has an upside for all users of being able to use the default animations as a base that they can extend upon, rather than having to copy/paste the entire effect to re-register it with |
By the way - just to confirm I'm not crazy :D, I tossed in https://github.com/cgwyllie/angular-velocity and unfortunately the same issue occurs with that library. |
For my own needs of getting my application live, I ended up just copy-pasting the full effects list from the UI pack and then doing:
The downside obviously being I'll need to do this whenever a cool new effect is added :/ Look forward to figuring out a proper solution together though! |
I have an idea of how I can provide you with access to the packaged effects JSON without polluting the Velocity namespace. Let me run it and make sure it doesn't cause errors anywhere. Then I'll chew on it for a night. Expect a concrete update tomorrow. |
Hey Julian, Just as a follow up from bed, I spent more time working on this. It appears Basically, I send the call to velocity WITHOUT providing a complete Doing the above, it works perfectly. That may well be a good enough solution since the issue seems quite Angular - specific. I wouldn't want you to mangle your codebase in any way to accommodate this strange issue. Just wanted to keep you updated on my progress.
|
Ahh interesting. I'm in the middle of carrying out your good suggestion of externalizing the packaged effects data for optional re-registration. I still think I'm going to do it regardless. Thank you so much for the update, Ross. |
OK. I just pushed it :) You can now access $.Velocity.RegisterUI.packagedEffects. Btw, in your plugin, make sure you follow the Container pattern seen in velocity.ui.js. Can't remember if you were doing that or not. |
Transition “out” effects don’t reset opacity to 1. This is the only default behavior change that has been made to the UI pack. Shouldn’t affect the vast majority of use cases. Performance improvements due to automatically forcefeeding all reset values. Fix reset timing bug in which reset occurs after user’s complete callback fires. Closes #132. Closes #129. Turned sequence registration into externally-accessible function. Closes #94. Closes #136. Added options customizability to calls. See http://VelocityJS.org/#uiPack.
I'm wrapping Velocity / Velocity UI into an AngularJS module at the moment, and to do so I'm running 'In' transitions, and then automatically prepping the element to run the corresponding "Out" animation when appropriate.
The issue comes when Velocity UI goes to run the completed callbacks after all effect calls have been run. In situations as described above, it actually needs to skip over the code block that runs between lines 518 and 526 if (effect.reset) evaluates to true.
Would it be possible to add an option (skipReset?) to optionally bypass that code block?
I can create a PR, I just need to know if you'd like the default value of false defined in Velocity's defaults. This would be a UI-Pack-only option so I'm not sure if it's appropriate to define it's default value in the parent library or not.
Thoughts?