OLD | NEW |
1 part of effects; | 1 part of effects; |
2 | 2 |
3 class ShowHideAction extends _Enum { | 3 class ShowHideAction extends _Enum { |
4 static const ShowHideAction SHOW = const ShowHideAction._internal("show"); | 4 static const ShowHideAction SHOW = const ShowHideAction._internal("show"); |
5 static const ShowHideAction HIDE = const ShowHideAction._internal('hide'); | 5 static const ShowHideAction HIDE = const ShowHideAction._internal('hide'); |
6 static const ShowHideAction TOGGLE = const ShowHideAction._internal('toggle'); | 6 static const ShowHideAction TOGGLE = const ShowHideAction._internal('toggle'); |
7 | 7 |
8 const ShowHideAction._internal(String name) : super(name); | 8 const ShowHideAction._internal(String name) : super(name); |
9 } | 9 } |
10 | 10 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 assert(element != null); | 146 assert(element != null); |
147 assert(desiredDuration != null); | 147 assert(desiredDuration != null); |
148 assert(effect != null); | 148 assert(effect != null); |
149 assert(effectTiming != null); | 149 assert(effectTiming != null); |
150 final values = _values[element]; | 150 final values = _values[element]; |
151 | 151 |
152 switch(values.currentState) { | 152 switch(values.currentState) { |
153 case ShowHideState.SHOWING: | 153 case ShowHideState.SHOWING: |
154 // no op - let the current animation finish | 154 // no op - let the current animation finish |
155 assert(_AnimatingValues.isAnimating(element)); | 155 assert(_AnimatingValues.isAnimating(element)); |
156 return new Future.immediate(ShowHideResult.NOOP); | 156 return new Future.value(ShowHideResult.NOOP); |
157 case ShowHideState.SHOWN: | 157 case ShowHideState.SHOWN: |
158 // no op. If shown leave it. | 158 // no op. If shown leave it. |
159 assert(!_AnimatingValues.isAnimating(element)); | 159 assert(!_AnimatingValues.isAnimating(element)); |
160 return new Future.immediate(ShowHideResult.NOOP); | 160 return new Future.value(ShowHideResult.NOOP); |
161 case ShowHideState.HIDING: | 161 case ShowHideState.HIDING: |
162 _AnimatingValues.cancelAnimation(element); | 162 _AnimatingValues.cancelAnimation(element); |
163 break; | 163 break; |
164 case ShowHideState.HIDDEN: | 164 case ShowHideState.HIDDEN: |
165 // handeled below with a fall-through | 165 // handeled below with a fall-through |
166 break; | 166 break; |
167 default: | 167 default: |
168 throw new DetailedArgumentError('oldState', 'the provided value ${values
.currentState} is not supported'); | 168 throw new DetailedArgumentError('oldState', 'the provided value ${values
.currentState} is not supported'); |
169 } | 169 } |
170 | 170 |
171 assert(!_AnimatingValues.isAnimating(element)); | 171 assert(!_AnimatingValues.isAnimating(element)); |
172 _finishShow(element); | 172 _finishShow(element); |
173 final durationMS = effect.startShow(element, desiredDuration, effectTiming); | 173 final durationMS = effect.startShow(element, desiredDuration, effectTiming); |
174 if(durationMS > 0) { | 174 if(durationMS > 0) { |
175 | 175 |
176 // _finishShow sets the currentState to shown, but we know better since we
're animating | 176 // _finishShow sets the currentState to shown, but we know better since we
're animating |
177 assert(values.currentState == ShowHideState.SHOWN); | 177 assert(values.currentState == ShowHideState.SHOWN); |
178 values.currentState = ShowHideState.SHOWING; | 178 values.currentState = ShowHideState.SHOWING; |
179 return _AnimatingValues.scheduleCleanup(durationMS, element, effect.clearA
nimation, _finishShow); | 179 return _AnimatingValues.scheduleCleanup(durationMS, element, effect.clearA
nimation, _finishShow); |
180 } else { | 180 } else { |
181 assert(values.currentState == ShowHideState.SHOWN); | 181 assert(values.currentState == ShowHideState.SHOWN); |
182 return new Future.immediate(ShowHideResult.IMMEDIATE); | 182 return new Future.value(ShowHideResult.IMMEDIATE); |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 static void _finishShow(Element element) { | 186 static void _finishShow(Element element) { |
187 final values = _values[element]; | 187 final values = _values[element]; |
188 assert(!_AnimatingValues.isAnimating(element)); | 188 assert(!_AnimatingValues.isAnimating(element)); |
189 element.style.display = _getShowDisplayValue(element); | 189 element.style.display = _getShowDisplayValue(element); |
190 values.currentState = ShowHideState.SHOWN; | 190 values.currentState = ShowHideState.SHOWN; |
191 } | 191 } |
192 | 192 |
193 static Future<ShowHideResult> _requestHide(Element element, int desiredDuratio
n, | 193 static Future<ShowHideResult> _requestHide(Element element, int desiredDuratio
n, |
194 ShowHideEffect effect, EffectTiming effectTiming) { | 194 ShowHideEffect effect, EffectTiming effectTiming) { |
195 assert(element != null); | 195 assert(element != null); |
196 assert(desiredDuration != null); | 196 assert(desiredDuration != null); |
197 assert(effect != null); | 197 assert(effect != null); |
198 assert(effectTiming != null); | 198 assert(effectTiming != null); |
199 final values = _values[element]; | 199 final values = _values[element]; |
200 | 200 |
201 switch(values.currentState) { | 201 switch(values.currentState) { |
202 case ShowHideState.HIDING: | 202 case ShowHideState.HIDING: |
203 // no op - let the current animation finish | 203 // no op - let the current animation finish |
204 assert(_AnimatingValues.isAnimating(element)); | 204 assert(_AnimatingValues.isAnimating(element)); |
205 return new Future.immediate(ShowHideResult.NOOP); | 205 return new Future.value(ShowHideResult.NOOP); |
206 case ShowHideState.HIDDEN: | 206 case ShowHideState.HIDDEN: |
207 // it's possible we're here because the inferred calculated value is 'no
ne' | 207 // it's possible we're here because the inferred calculated value is 'no
ne' |
208 // this hard-wires the local display value to 'none'...just to be clear | 208 // this hard-wires the local display value to 'none'...just to be clear |
209 _finishHide(element); | 209 _finishHide(element); |
210 return new Future.immediate(ShowHideResult.NOOP); | 210 return new Future.value(ShowHideResult.NOOP); |
211 case ShowHideState.SHOWING: | 211 case ShowHideState.SHOWING: |
212 _AnimatingValues.cancelAnimation(element); | 212 _AnimatingValues.cancelAnimation(element); |
213 break; | 213 break; |
214 case ShowHideState.SHOWN: | 214 case ShowHideState.SHOWN: |
215 // handeled below with a fall-through | 215 // handeled below with a fall-through |
216 break; | 216 break; |
217 default: | 217 default: |
218 throw new DetailedArgumentError('oldState', 'the provided value ${values
.currentState} is not supported'); | 218 throw new DetailedArgumentError('oldState', 'the provided value ${values
.currentState} is not supported'); |
219 } | 219 } |
220 | 220 |
221 assert(!_AnimatingValues.isAnimating(element)); | 221 assert(!_AnimatingValues.isAnimating(element)); |
222 final durationMS = effect.startHide(element, desiredDuration, effectTiming); | 222 final durationMS = effect.startHide(element, desiredDuration, effectTiming); |
223 if(durationMS > 0) { | 223 if(durationMS > 0) { |
224 _values[element].currentState = ShowHideState.HIDING; | 224 _values[element].currentState = ShowHideState.HIDING; |
225 return _AnimatingValues.scheduleCleanup(durationMS, element, effect.clearA
nimation, _finishHide); | 225 return _AnimatingValues.scheduleCleanup(durationMS, element, effect.clearA
nimation, _finishHide); |
226 } else { | 226 } else { |
227 _finishHide(element); | 227 _finishHide(element); |
228 assert(values.currentState == ShowHideState.HIDDEN); | 228 assert(values.currentState == ShowHideState.HIDDEN); |
229 return new Future.immediate(ShowHideResult.IMMEDIATE); | 229 return new Future.value(ShowHideResult.IMMEDIATE); |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 static void _finishHide(Element element) { | 233 static void _finishHide(Element element) { |
234 final values = _values[element]; | 234 final values = _values[element]; |
235 assert(!_AnimatingValues.isAnimating(element)); | 235 assert(!_AnimatingValues.isAnimating(element)); |
236 element.style.display = 'none'; | 236 element.style.display = 'none'; |
237 values.currentState = ShowHideState.HIDDEN; | 237 values.currentState = ShowHideState.HIDDEN; |
238 } | 238 } |
239 | 239 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 } | 322 } |
323 | 323 |
324 static Future<ShowHideResult> scheduleCleanup(int durationMS, Element element, | 324 static Future<ShowHideResult> scheduleCleanup(int durationMS, Element element, |
325 Action1<Element> cleanupAction, | 325 Action1<Element> cleanupAction, |
326 Action1<Element> finishAction) { | 326 Action1<Element> finishAction) { |
327 | 327 |
328 final value = new _AnimatingValues._internal(element, cleanupAction, finishA
ction); | 328 final value = new _AnimatingValues._internal(element, cleanupAction, finishA
ction); |
329 return value._start(durationMS); | 329 return value._start(durationMS); |
330 } | 330 } |
331 } | 331 } |
OLD | NEW |