(definition: AnimationDefinition | TouchAnimationFn)
| 181 | static startAnimationForType(view: View, type: TouchAnimationTypes) { |
| 182 | if (view) { |
| 183 | const animate = function (definition: AnimationDefinition | TouchAnimationFn) { |
| 184 | if (definition) { |
| 185 | if (isFunction(definition)) { |
| 186 | (<TouchAnimationFn>definition)(view); |
| 187 | } else { |
| 188 | if (!TouchManager.touchAnimationDefinitions) { |
| 189 | TouchManager.touchAnimationDefinitions = []; |
| 190 | } |
| 191 | // reuse animations for each type |
| 192 | let touchAnimation: Animation; |
| 193 | // triggering animations should always cancel other animations which may be in progress |
| 194 | for (const d of TouchManager.touchAnimationDefinitions) { |
| 195 | if (d.view === view && d.animation) { |
| 196 | d.animation.cancel(); |
| 197 | if (d.type === type) { |
| 198 | touchAnimation = d.animation; |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | if (!touchAnimation) { |
| 204 | touchAnimation = new Animation([ |
| 205 | { |
| 206 | target: view, |
| 207 | ...(<AnimationDefinition>definition), |
| 208 | }, |
| 209 | ]); |
| 210 | TouchManager.touchAnimationDefinitions.push({ |
| 211 | view, |
| 212 | type, |
| 213 | animation: touchAnimation, |
| 214 | }); |
| 215 | } |
| 216 | touchAnimation.play().catch(() => {}); |
| 217 | } |
| 218 | } |
| 219 | }; |
| 220 | // always use instance defined animation over global |
| 221 | if (isObject(view.touchAnimation) && view.touchAnimation[type]) { |
| 222 | animate(view.touchAnimation[type]); |
no test coverage detected