1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | import animit from '../../ons/animit.js';
|
19 | import BaseAnimator from '../../ons/base-animator.js';
|
20 | import iPhoneXPatch from '../../ons/iphonex-patch.js';
|
21 |
|
22 | export class ActionSheetAnimator extends BaseAnimator {
|
23 |
|
24 | constructor({timing = 'linear', delay = 0, duration = 0.2} = {}) {
|
25 | super({ timing, delay, duration });
|
26 | }
|
27 |
|
28 | |
29 |
|
30 |
|
31 |
|
32 | show(dialog, done) {
|
33 | done();
|
34 | }
|
35 |
|
36 | |
37 |
|
38 |
|
39 |
|
40 | hide(dialog, done) {
|
41 | done();
|
42 | }
|
43 | }
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | export class MDActionSheetAnimator extends ActionSheetAnimator {
|
49 |
|
50 | constructor({ timing = 'ease', delay = 0, duration = 0.4 } = {}) {
|
51 | super({timing, delay, duration});
|
52 |
|
53 | this.maskTiming = 'linear';
|
54 | this.maskDuration = 0.2;
|
55 | }
|
56 |
|
57 | |
58 |
|
59 |
|
60 |
|
61 | show(dialog, callback) {
|
62 |
|
63 | animit.runAll(
|
64 | animit(dialog._mask)
|
65 | .queue({ opacity: 0 })
|
66 | .wait(this.delay)
|
67 | .queue({ opacity: 1.0 }, {
|
68 | duration: this.maskDuration,
|
69 | timing: this.maskTiming
|
70 | }),
|
71 |
|
72 | animit(dialog._sheet, this.def)
|
73 | .default(
|
74 | { transform: `translate3d(0, 80%, 0)`, opacity: 0 },
|
75 | { transform: 'translate3d(0, 0, 0)', opacity: 1 }
|
76 | )
|
77 | .queue(done => {
|
78 | callback && callback();
|
79 | done();
|
80 | })
|
81 | );
|
82 | }
|
83 |
|
84 | |
85 |
|
86 |
|
87 |
|
88 | hide(dialog, callback) {
|
89 | animit.runAll(
|
90 |
|
91 | animit(dialog._mask)
|
92 | .queue({ opacity: 1 })
|
93 | .wait(this.delay)
|
94 | .queue({ opacity: 0 }, {
|
95 | duration: this.maskDuration,
|
96 | timing: this.maskTiming
|
97 | }),
|
98 |
|
99 | animit(dialog._sheet, this.def)
|
100 | .default(
|
101 | { transform: 'translate3d(0, 0, 0)', opacity: 1 },
|
102 | { transform: `translate3d(0, 80%, 0)`, opacity: 0 }
|
103 | )
|
104 | .queue(done => {
|
105 | callback && callback();
|
106 | done();
|
107 | })
|
108 | );
|
109 | }
|
110 | }
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | export class IOSActionSheetAnimator extends ActionSheetAnimator {
|
116 |
|
117 | constructor({ timing = 'ease', delay = 0, duration = 0.3 } = {}) {
|
118 | super({timing, delay, duration});
|
119 |
|
120 | this.maskTiming = 'linear';
|
121 | this.maskDuration = 0.2;
|
122 | if (iPhoneXPatch.isIPhoneXPortraitPatchActive()) {
|
123 | this.liftAmount = 'calc(100% + 48px)';
|
124 | } else if (iPhoneXPatch.isIPhoneXLandscapePatchActive()) {
|
125 | this.liftAmount = 'calc(100% + 33px)';
|
126 | } else {
|
127 | this.liftAmount = document.body.clientHeight / 2.0 - 1 + 'px';
|
128 | }
|
129 | }
|
130 |
|
131 | |
132 |
|
133 |
|
134 |
|
135 | show(dialog, callback) {
|
136 | animit.runAll(
|
137 |
|
138 | animit(dialog._mask)
|
139 | .queue({ opacity: 0 })
|
140 | .wait(this.delay)
|
141 | .queue({ opacity: 1 }, {
|
142 | duration: this.maskDuration,
|
143 | timing: this.maskTiming
|
144 | }),
|
145 |
|
146 | animit(dialog._sheet, this.def)
|
147 | .default(
|
148 | { transform: `translate3d(0, ${this.liftAmount}, 0)` },
|
149 | { transform: 'translate3d(0, 0, 0)' }
|
150 | )
|
151 | .queue(done => {
|
152 | callback && callback();
|
153 | done();
|
154 | })
|
155 | );
|
156 | }
|
157 |
|
158 | |
159 |
|
160 |
|
161 |
|
162 | hide(dialog, callback) {
|
163 | animit.runAll(
|
164 |
|
165 | animit(dialog._mask)
|
166 | .queue({ opacity: 1 })
|
167 | .wait(this.delay)
|
168 | .queue({ opacity: 0 }, {
|
169 | duration: this.maskDuration,
|
170 | timing: this.maskTiming
|
171 | }),
|
172 |
|
173 | animit(dialog._sheet, this.def)
|
174 | .default(
|
175 | { transform: 'translate3d(0, 0, 0)' },
|
176 | { transform: `translate3d(0, ${this.liftAmount}, 0)` }
|
177 | )
|
178 | .queue(done => {
|
179 | callback && callback();
|
180 | done();
|
181 | })
|
182 | );
|
183 | }
|
184 | }
|