-
Notifications
You must be signed in to change notification settings - Fork 239
/
Copy pathTransition.js
61 lines (57 loc) · 1.82 KB
/
Transition.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Copyright (c) 2023 Moddable Tech, Inc.
*
* This file is part of the Moddable SDK.
*
* This work is licensed under the
* Creative Commons Attribution 4.0 International License.
* To view a copy of this license, visit
* <http://creativecommons.org/licenses/by/4.0>.
* or send a letter to Creative Commons, PO Box 1866,
* Mountain View, CA 94042, USA.
*
*/
import WipeTransition from "piu/WipeTransition";
export class HorizontalTransition extends WipeTransition {
constructor(backwards) {
super(500, Math.quadEaseOut, backwards ? "left" : "right");
}
onBegin(application, container, fromView, Template, toView) {
this.container = application;
application.add(new Template(toView));
this.die = new Die(null, {regionLength: 32}); //@@ how to size this?
this.die.attach(application.last);
this.width = this.die.width;
this.height = this.die.height;
}
onEnd(application, container, fromView, Template, toView) {
this.die.detach();
application.remove(container);
fromView.purge();
delete this.die;
delete this.container;
}
}
Object.freeze(HorizontalTransition.prototype);
export class VerticalTransition extends WipeTransition {
constructor(backwards) {
super(500, Math.quadEaseOut, backwards ? "top" : "bottom");
}
onBegin(application, container, fromView, Template, toView) {
this.container = application;
application.add(new Template(toView));
this.die = new Die(null, {regionLength: 32}); //@@ how to size this?
this.die.attach(application.last);
this.width = this.die.width;
this.height = this.die.height;
}
onEnd(application, container, fromView, Template, toView) {
this.die.detach();
application.remove(container);
fromView.purge();
delete this.die;
delete this.container;
}
}
Object.freeze(VerticalTransition.prototype);
export default HorizontalTransition;