Files
NativeScript/tns-core-modules/ui/transition/slide-transition.ios.ts
Panayot Cankov 1236f66f44 Add npm script that generates ios .d.ts-es from the tests app
Less than 30 erros left, let's hope it still works

Added lib.*.d.ts from typescript, removed lib and dom stuff, added by hand XHR, alert etc. .d.ts-es for polyfills

Roll back some changes involved in separating UIEvent for dom and ios

Test combined dts-es will now use lib, while internally we will not to avoid UIEvent conflict with dom stuff
2016-08-29 09:58:17 +03:00

70 lines
2.9 KiB
TypeScript

import transition = require("ui/transition");
import platform = require("platform");
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;
constructor(direction: string, duration: number, curve: any) {
super(duration, curve);
this._direction = direction;
}
public animateIOSTransition(containerView: UIView, fromView: UIView, toView: UIView, operation: UINavigationControllerOperation, completion: (finished: boolean) => void): void {
let originalToViewTransform = toView.transform;
let originalFromViewTransform = fromView.transform;
let fromViewEndTransform: CGAffineTransform;
let toViewBeginTransform: CGAffineTransform;
let push = (operation === UINavigationControllerOperation.Push);
switch (this._direction) {
case "left":
toViewBeginTransform = push ? rightEdge : leftEdge;
fromViewEndTransform = push ? leftEdge : rightEdge;
break;
case "right":
toViewBeginTransform = push ? leftEdge : rightEdge;
fromViewEndTransform = push ? rightEdge : leftEdge;
break;
case "top":
toViewBeginTransform = push ? bottomEdge : topEdge;
fromViewEndTransform = push ? topEdge : bottomEdge;
break;
case "bottom":
toViewBeginTransform = push ? topEdge : bottomEdge;
fromViewEndTransform = push ? bottomEdge : topEdge;
break;
}
toView.transform = toViewBeginTransform;
fromView.transform = CGAffineTransformIdentity;
switch (operation) {
case UINavigationControllerOperation.Push:
containerView.insertSubviewAboveSubview(toView, fromView);
break;
case UINavigationControllerOperation.Pop:
containerView.insertSubviewBelowSubview(toView, fromView);
break;
}
let duration = this.getDuration();
let curve = this.getCurve();
UIView.animateWithDurationAnimationsCompletion(duration, () => {
UIView.setAnimationCurve(curve);
toView.transform = CGAffineTransformIdentity;
fromView.transform = fromViewEndTransform;
}, (finished: boolean) => {
toView.transform = originalToViewTransform;
fromView.transform = originalFromViewTransform;
completion(finished);
});
}
}