(args)
| 1 | import { getViewById, View, Page, Button, SegmentedBar, SegmentedBarItem, Label, Animation, AnimationDefinition } from '@nativescript/core'; |
| 2 | |
| 3 | export function easeAnimate(args) { |
| 4 | const clicked = args.object as Button; |
| 5 | const page: Page = clicked.page; |
| 6 | const target = getViewById(page, 'target') as Label; |
| 7 | const select = getViewById(page, 'select') as SegmentedBar; |
| 8 | const item: SegmentedBarItem = select.items[select.selectedIndex]; |
| 9 | const easeType: string = clicked.text; |
| 10 | const extent = 128; |
| 11 | let duration = easeType === 'spring' ? 800 : 500; |
| 12 | let delay = easeType === 'spring' ? 0 : 200; |
| 13 | let animateKey: string = null; |
| 14 | let animateValueTo: any = null; |
| 15 | let animateValueFrom: any = null; |
| 16 | |
| 17 | switch (item.title) { |
| 18 | case 'height': |
| 19 | animateKey = 'height'; |
| 20 | target.originX = target.originY = 0; |
| 21 | animateValueTo = 0; |
| 22 | animateValueFrom = extent; |
| 23 | break; |
| 24 | case 'width': |
| 25 | animateKey = 'width'; |
| 26 | target.originX = target.originY = 0; |
| 27 | animateValueTo = 0; |
| 28 | animateValueFrom = extent; |
| 29 | break; |
| 30 | case 'opacity': |
| 31 | animateKey = 'opacity'; |
| 32 | animateValueTo = 0; |
| 33 | animateValueFrom = 1; |
| 34 | break; |
| 35 | case 'color': |
| 36 | animateKey = 'backgroundColor'; |
| 37 | animateValueTo = 'blue'; |
| 38 | animateValueFrom = 'purple'; |
| 39 | break; |
| 40 | case 'rotate': |
| 41 | animateKey = 'rotate'; |
| 42 | target.originX = target.originY = 0.5; |
| 43 | animateValueTo = 180; |
| 44 | animateValueFrom = 0; |
| 45 | break; |
| 46 | case 'scale': |
| 47 | animateKey = 'scale'; |
| 48 | target.originX = target.originY = 0.5; |
| 49 | animateValueTo = { x: 1.5, y: 1.5 }; |
| 50 | animateValueFrom = { x: 1, y: 1 }; |
| 51 | break; |
| 52 | } |
| 53 | target |
| 54 | .animate({ |
| 55 | [animateKey]: animateValueTo, |
| 56 | duration, |
| 57 | curve: easeType, |
| 58 | }) |
| 59 | .then(() => { |
| 60 | return target.animate({ |
nothing calls this directly
no test coverage detected