You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/12/12 13:18:49 UTC
[GitHub] [cordova-plugin-splashscreen] bnfrnz commented on issue #225:
fix(android): Back button fix for SDK28
bnfrnz commented on issue #225: fix(android): Back button fix for SDK28
URL: https://github.com/apache/cordova-plugin-splashscreen/pull/225#issuecomment-565003314
@IntellectBizMobility, we needed custom page transitions as well and ended up writing them ourselves using CSS animations.
Here an example for a vertical slide:
```
import { Animation } from 'ionic-angular/animations/animation';
import { PageTransition } from 'ionic-angular/transitions/page-transition';
import { isPresent } from 'ionic-angular/util/util';
export class VerticalSlideTransition extends PageTransition {
init(): void {
try {
super.init();
this.duration(isPresent(this.opts.duration) ? this.opts.duration : 500); //Default duration: 500mms
this.easing(isPresent(this.opts.easing) ? this.opts.easing : 'ease-in-out'); //Default easing: ease-in-out
// Push transition:
if (this.opts.direction === 'forward') {
if (this.enteringView) {
const enteringContent: Animation = new Animation(this.plt, this.enteringView.pageRef());
this.add(enteringContent.fromTo('translateY', '100%', '0', true));
}
if (this.leavingView && this.leavingView.pageRef()) {
const leavingContent: Animation = new Animation(this.plt, this.leavingView.pageRef());
this.add(leavingContent.fromTo('translateY', '0', '0', true));
}
}
// Pop transition:
else if (this.opts.direction === 'back') {
if (this.enteringView) {
const enteringContent: Animation = new Animation(this.plt, this.enteringView.pageRef());
this.add(enteringContent.fromTo('translateY', '0', '0', true));
}
if (this.leavingView && this.leavingView.pageRef()) {
const leavingContent: Animation = new Animation(this.plt, this.leavingView.pageRef());
this.add(leavingContent.fromTo('translateY', '0', '100%', false));
}
}
} catch (err) {
console.error(err);
}
}
}
```
Then, in your app.component.ts register your transition to your config:
```
this.config.setTransition('vertical-slide', VerticalSlideTransition);
```
And then use it like so:
```
const navOpts: NavOptions = {
animation: 'vertical-slide',
direction: 'forward',
duration: 400,
easing: 'ease-in-out'
};
this.navCtrl.push('NewPage', navParams, navOpts);
```
You can pretty much build whatever transition you want. It's really just [CSS animations](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations) wrapped in JavaScript.
In theory, they may be less performant than the native transitions but we didn't see any issues with newer phones.
As far as I remember, the native page transitions plugin isn't being maintained anymore, so we were actually happy to remove it, as keeping it just promises more issues down the road. The whole Cordova ecosystem is quite bad in that a lot of plugins (even really basic ones like this splash screen) aren't maintained properly. And frameworks like Ionic 3 (who are reliant on Cordova plugins and claim to offer a "curated" set of them) don't do anything about it either. I mean, it's free... and that's great... but it's also quite pointless if every other time some library is being updated something breaks and no one fixes it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org