mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #2286 from NativeScript/transitions
Fixed a visual glitch with manual iOS transitions
This commit is contained in:
@@ -77,6 +77,10 @@ export class Frame extends frameCommon.Frame {
|
||||
throw new Error("Required page does not have a viewController created.");
|
||||
}
|
||||
|
||||
let clearHistory = backstackEntry.entry.clearHistory;
|
||||
if (clearHistory) {
|
||||
navDepth = -1;
|
||||
}
|
||||
navDepth++;
|
||||
|
||||
let navigationTransition: definition.NavigationTransition;
|
||||
@@ -117,7 +121,7 @@ export class Frame extends frameCommon.Frame {
|
||||
}
|
||||
|
||||
// We should clear the entire history.
|
||||
if (backstackEntry.entry.clearHistory) {
|
||||
if (clearHistory) {
|
||||
viewController.navigationItem.hidesBackButton = true;
|
||||
var newControllers = NSMutableArray.alloc().initWithCapacity(1);
|
||||
newControllers.addObject(viewController);
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
export class FadeTransition extends transition.Transition {
|
||||
public animateIOSTransition(containerView: UIView, fromView: UIView, toView: UIView, operation: UINavigationControllerOperation, completion: (finished: boolean) => void): void {
|
||||
let originalToViewAlpha = toView.alpha;
|
||||
let originalFromViewAlpha = fromView.alpha;
|
||||
|
||||
toView.alpha = 0.0;
|
||||
fromView.alpha = 1.0;
|
||||
|
||||
@@ -14,12 +17,16 @@ export class FadeTransition extends transition.Transition {
|
||||
break;
|
||||
}
|
||||
|
||||
var duration = this.getDuration();
|
||||
var curve = this.getCurve();
|
||||
let duration = this.getDuration();
|
||||
let curve = this.getCurve();
|
||||
UIView.animateWithDurationAnimationsCompletion(duration, () => {
|
||||
UIView.setAnimationCurve(curve);
|
||||
toView.alpha = 1.0;
|
||||
fromView.alpha = 0.0;
|
||||
}, completion);
|
||||
}, (finished: boolean) => {
|
||||
toView.alpha = originalToViewAlpha;
|
||||
fromView.alpha = originalFromViewAlpha;
|
||||
completion(finished);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import transition = require("ui/transition");
|
||||
import platform = require("platform");
|
||||
|
||||
var screenWidth = platform.screen.mainScreen.widthDIPs;
|
||||
var screenHeight = platform.screen.mainScreen.heightDIPs;
|
||||
var leftEdge = CGAffineTransformMakeTranslation(-screenWidth, 0);
|
||||
var rightEdge = CGAffineTransformMakeTranslation(screenWidth, 0);
|
||||
var topEdge = CGAffineTransformMakeTranslation(0, -screenHeight);
|
||||
var bottomEdge = CGAffineTransformMakeTranslation(0, screenHeight);
|
||||
let screenWidth = platform.screen.mainScreen.widthDIPs;
|
||||
let screenHeight = platform.screen.mainScreen.heightDIPs;
|
||||
let leftEdge = CGAffineTransformMakeTranslation(-screenWidth, 0);
|
||||
let rightEdge = CGAffineTransformMakeTranslation(screenWidth, 0);
|
||||
let topEdge = CGAffineTransformMakeTranslation(0, -screenHeight);
|
||||
let bottomEdge = CGAffineTransformMakeTranslation(0, screenHeight);
|
||||
|
||||
export class SlideTransition extends transition.Transition {
|
||||
private _direction: string;
|
||||
@@ -17,9 +17,12 @@ export class SlideTransition extends transition.Transition {
|
||||
}
|
||||
|
||||
public animateIOSTransition(containerView: UIView, fromView: UIView, toView: UIView, operation: UINavigationControllerOperation, completion: (finished: boolean) => void): void {
|
||||
var fromViewEndTransform: CGAffineTransform;
|
||||
var toViewBeginTransform: CGAffineTransform;
|
||||
var push = (operation === UINavigationControllerOperation.UINavigationControllerOperationPush);
|
||||
let originalToViewTransform = toView.transform;
|
||||
let originalFromViewTransform = fromView.transform;
|
||||
|
||||
let fromViewEndTransform: CGAffineTransform;
|
||||
let toViewBeginTransform: CGAffineTransform;
|
||||
let push = (operation === UINavigationControllerOperation.UINavigationControllerOperationPush);
|
||||
|
||||
switch (this._direction) {
|
||||
case "left":
|
||||
@@ -52,12 +55,16 @@ export class SlideTransition extends transition.Transition {
|
||||
break;
|
||||
}
|
||||
|
||||
var duration = this.getDuration();
|
||||
var curve = this.getCurve();
|
||||
let duration = this.getDuration();
|
||||
let curve = this.getCurve();
|
||||
UIView.animateWithDurationAnimationsCompletion(duration, () => {
|
||||
UIView.setAnimationCurve(curve);
|
||||
toView.transform = CGAffineTransformIdentity;
|
||||
fromView.transform = fromViewEndTransform;
|
||||
}, completion);
|
||||
}, (finished: boolean) => {
|
||||
toView.transform = originalToViewTransform;
|
||||
fromView.transform = originalFromViewTransform;
|
||||
completion(finished);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user