UNPKG

2.92 kBJavaScriptView Raw
1import { CORE_ANIMATION_DEFAULTS } from '../../utils/common';
2import { Transition } from '.';
3export class FadeTransition extends Transition {
4 iosNavigatedController(navigationController, operation, fromVC, toVC) {
5 this.transitionController = FadeTransitionController.initWithOwner(new WeakRef(this));
6 this.presented = toVC;
7 this.presenting = fromVC;
8 this.operation = operation;
9 // console.log('presenting:', this.presenting);
10 return this.transitionController;
11 }
12}
13var FadeTransitionController = /** @class */ (function (_super) {
14 __extends(FadeTransitionController, _super);
15 function FadeTransitionController() {
16 return _super !== null && _super.apply(this, arguments) || this;
17 }
18 FadeTransitionController.initWithOwner = function (owner) {
19 var ctrl = FadeTransitionController.new();
20 ctrl.owner = owner;
21 return ctrl;
22 };
23 FadeTransitionController.prototype.transitionDuration = function (transitionContext) {
24 var owner = this.owner.deref();
25 if (owner) {
26 return owner.getDuration();
27 }
28 return CORE_ANIMATION_DEFAULTS.duration;
29 };
30 FadeTransitionController.prototype.animateTransition = function (transitionContext) {
31 var owner = this.owner.deref();
32 if (owner) {
33 // console.log('FadeTransitionController animateTransition:', owner.operation);
34 var toView_1 = owner.presented.view;
35 var originalToViewAlpha_1 = toView_1.alpha;
36 var fromView_1 = owner.presenting.view;
37 var originalFromViewAlpha_1 = fromView_1.alpha;
38 toView_1.alpha = 0.0;
39 fromView_1.alpha = 1.0;
40 switch (owner.operation) {
41 case UINavigationControllerOperation.Push:
42 transitionContext.containerView.insertSubviewAboveSubview(toView_1, fromView_1);
43 break;
44 case UINavigationControllerOperation.Pop:
45 transitionContext.containerView.insertSubviewBelowSubview(toView_1, fromView_1);
46 break;
47 }
48 var duration = owner.getDuration();
49 var curve_1 = owner.getCurve();
50 UIView.animateWithDurationAnimationsCompletion(duration, function () {
51 UIView.setAnimationCurve(curve_1);
52 toView_1.alpha = 1.0;
53 fromView_1.alpha = 0.0;
54 }, function (finished) {
55 toView_1.alpha = originalToViewAlpha_1;
56 fromView_1.alpha = originalFromViewAlpha_1;
57 transitionContext.completeTransition(finished);
58 });
59 }
60 };
61 FadeTransitionController.ObjCProtocols = [UIViewControllerAnimatedTransitioning];
62 return FadeTransitionController;
63}(NSObject));
64export { FadeTransitionController };
65//# sourceMappingURL=fade-transition.ios.js.map
\No newline at end of file