-
Notifications
You must be signed in to change notification settings - Fork 107
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
An alternative to configuring delay values #62
Comments
Excellent idea. If anyone want to pick this up, go ahead. Alternatively you'll need to wait a while until I have time to pick up this great suggestion. |
I took some time to play with the code, but as someone with zero native ios/android/windows experience, it is a pretty daunting task. Hopefully someone can pick this up soon, as I think it would add huge value to the plugin and the overall cordova ecosystem. Coupled with your flavor of virtual-dom framework, this plugin is a killer, killer combination for creating cross-platform apps in javascript that are practically indistinguishable from fully native apps. |
Hey @tropperstyle which platform would you be interested in testing this with first? |
I am currently working with iOS |
This feature is exactly what this plugin need to be perfect. Hope to see it implemented soon. I work both on android and iOS and I would be glad to test it. ps: thanks for this awesome plugin. Really, this plugin is amazing, hybrid app need plugin like that (do you have a donation link ?). |
+1 |
Still looking for help with this? |
+1 |
Hey guys, I've now added this feature for iOS's slide transition. Android will follow real soon, but I thought I'd push it so you can give it a spin. Usage: pass When using an window.plugins.nativepagetransitions.executePendingTransition();
// or with the optional callbacks:
window.plugins.nativepagetransitions.executePendingTransition(
function (msg) {console.log("success: " + msg)}, // called when the animation has finished
function (msg) {alert("error: " + msg)} // called in case or touble
); Only available in the master repo, you'll get |
@EddyVerbruggen Happy to see you working on it. Will test on it when the Android version is ready. |
@NgYueHong Android support for slide has also been added, please give it a spin, see the example code above. |
@EddyVerbruggen, would it make sense to have an option that would either generate or take a promise that when resolved will slide the new view in? I don't see the need to have to invoke two methods when I can just resolve a promise when I'm done. Something like:
or even:
hubspot does something similar with their beforeShowPromise in http://github.hubspot.com/shepherd/ EDIT: while this is definitely how I want this to work, I understand that we are sending these options to the native code and resolving the deferred object in the js side, doesn't carry over into the native code. I'll look into seeing if you can use promises across native/js code. My guess is that you can't. |
Hook it up like you want, I don't see what problem it solves in this context. |
Okay, easy add on to your code.
|
You can also use the presence of the promise to determine whether or not to hold off executing the transition immediately instead of playing games with the delays. Also, you don't have to publically expose the new method executePendingTransition as it can be a private helper method inside the www/NativePageTransitions.js |
And that works for everyone? |
I have time to work on this today. Permission to attempt a pull request? |
Of course and I really appreciate it. Try to do only slide and see if folks like it. |
I'll chime in... I think the API can be simplified even further. Instead of adding yet another option like |
Haven't yet gotten to resolveAfter, which it sounds like is a good thing since we're still discussing possible API's. But I did create a pull request for android to clean up the transition types: #77 I'd be okay with making the delay option take a number or a promise. Do we want number, promise, or function that returns a promise? |
Thinking about it some more. One problem that came up immediately is that you will want to make sure the transition method is invoked before your async code. I think we can ditch thinking about promises, and use a thunk-like function. // Updating the href triggers a route change in my application code, so this fires DOM reconstruction.
window.plugins.nativepagetransitions.slide({
href: '#/some/route',
iosdelay: function(animate) {
// invoke animate function whenever you are ready
afterNextRedraw(function() { animate() });
}
}); This gives you all the functionality without worrying about device support for the Promise spec, and without any extra API methods or additional options. |
That sounds fine. @tropperstyle is that similar to express's next function? |
… of integer to control when animating pending transition happens
My pull request now includes this update. Up for hearing how to make it cleaner if necessary.
|
@EddyVerbruggen I have tested on my Android devices by setting It works great. Exactly how I wanted. 100% control when to capture screenshot and animate. No more animate too soon or too late issue!!!! Great work @EddyVerbruggen . Really appreciate it. Will share with others about this. Hope to see it works on other transition as well soon. Thanks. |
Thanks for testing this new feature all! I have now added the Available in 0.5.0. Enjoy, |
Hey @EddyVerbruggen what's the state of my pull request for this issue? Did you look at it? |
…s. Added iOS flip support.
…s. Added Android flip support.
…s. Added Android fade and drawer support.
…s. Added iOS fade and drawer support.
…s. Added iOS curl support.
… of integer to control when animating pending transition happens
@EddyVerbruggen, I tested on iOS and was able to see changes in the html before executing the pending transition. It's like the screenshot was not overlayed during the first step. This is how I tested:
And the height was changed, then the slide transition happend. Are we sure that the screenshot is actually used? I think this issue needs to be reopened or a new bug opened. Btw, this error happens in my pull request and master. NOTE: Android works perfectly. |
@kentmw That's expected behavior. Cordova plugins are asynchronous, so the call to That's also the reasons I've added the If you want to test this with a simple css change (without passing the |
@EddyVerbruggen, I actually had that same thought. And I did test that:
Yields the same bad results. 1 second should be more than enough time to overlay the screenshot. EDIT: same with 10/20 seconds
This doesn't show any changes even without a timeout on the css change. Do you think maybe the call to [UIView animateWithDuration:duration] is actually the call that is hiding any rendering, not the overlaying screenshot? |
Aha, that's an interesting observation! Let me dive into that.. |
@kentmw You found a bug sir, have a beer 🍺 Slide right was ok, slide left wasn't. It is in 0.5.1. |
Yay! Thanks for identifying where the problem was and adding the fix quickly. EDIT: beautiful. works great after testing. Now the executePendingTransition also works for left slides. |
Here's a little interesting piece of info to keep in mind when thinking about animations and custom delays: |
That sounds great, but that's actually pretty hard to do, and will always be error prone. As an alternative to tweaking delay values to sync animation and content changes, it would be great if the screenshot process and animation start time could be separated out and the latter manually invoked. I use a virtual dom framework and I know exactly when the new content is redrawn and ready to go, but the exact time in ms will not always be so consistent across devices.
I suggest something along these lines:
The text was updated successfully, but these errors were encountered: