Skip to content

Commit a7620d2

Browse files
committed
fix(view): prevent flicker when changing tabs on android
When android changes tabs, there was slight delay between the view becoming the cached view and the new tab becoming the active view. Similar to how iOS's tab swap animation works, passing in opacity prevents the leaving view from dissepearing too early, allowing for a much smoother animation.
1 parent e2727d2 commit a7620d2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: js/angular/service/ionicConfig.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -487,27 +487,28 @@ IonicModule
487487
provider.transitions.views.android = function(enteringEle, leavingEle, direction, shouldAnimate) {
488488
shouldAnimate = shouldAnimate && (direction == 'forward' || direction == 'back');
489489

490-
function setStyles(ele, x) {
490+
function setStyles(ele, x, opacity) {
491491
var css = {};
492492
css[ionic.CSS.TRANSITION_DURATION] = d.shouldAnimate ? '' : 0;
493493
css[ionic.CSS.TRANSFORM] = 'translate3d(' + x + '%,0,0)';
494+
css.opacity = opacity;
494495
ionic.DomUtil.cachedStyles(ele, css);
495496
}
496497

497498
var d = {
498499
run: function(step) {
499500
if (direction == 'forward') {
500-
setStyles(enteringEle, (1 - step) * 99); // starting at 98% prevents a flicker
501-
setStyles(leavingEle, step * -100);
501+
setStyles(enteringEle, (1 - step) * 99, 1); // starting at 98% prevents a flicker
502+
setStyles(leavingEle, step * -100, 1);
502503

503504
} else if (direction == 'back') {
504-
setStyles(enteringEle, (1 - step) * -100);
505-
setStyles(leavingEle, step * 100);
505+
setStyles(enteringEle, (1 - step) * -100, 1);
506+
setStyles(leavingEle, step * 100, 1);
506507

507508
} else {
508509
// swap, enter, exit
509-
setStyles(enteringEle, 0);
510-
setStyles(leavingEle, 0);
510+
setStyles(enteringEle, 0, 1);
511+
setStyles(leavingEle, 0, 0);
511512
}
512513
},
513514
shouldAnimate: shouldAnimate

0 commit comments

Comments
 (0)