UNPKG

3.07 kBTypeScriptView Raw
1import { Animation } from '../animation';
2import { AnimationDefinition } from '../animation/animation-interfaces';
3import { View } from '../core/view';
4export type TouchAnimationFn = (view: View) => void;
5export type TouchAnimationOptions = {
6 up?: TouchAnimationFn | AnimationDefinition;
7 down?: TouchAnimationFn | AnimationDefinition;
8};
9export declare enum TouchAnimationTypes {
10 up = "up",
11 down = "down"
12}
13export type VisionHoverEffect = 'automatic' | 'highlight' | 'lift';
14export type VisionHoverShape = 'circle' | 'rect';
15export type VisionHoverOptions = {
16 effect: VisionHoverEffect;
17 shape?: VisionHoverShape;
18 shapeCornerRadius?: number;
19};
20/**
21 * Manage interactivity in your apps easily with TouchManager.
22 * Store reusable down/up animation settings for touches as well as optionally enable automatic tap (down/up) animations for your app.
23 */
24export declare class TouchManager {
25 /**
26 * Enable animations for all tap bindings in the UI.
27 */
28 static enableGlobalTapAnimations: boolean;
29 /**
30 * (visionOS Only) Enable hoverStyle for all tap bindings in the UI.
31 */
32 static enableGlobalHoverWhereTap: boolean;
33 /**
34 * Define reusable hover styles keyed by name to use throughout your UI.
35 */
36 static visionHoverOptions: {
37 [key: string]: VisionHoverOptions;
38 };
39 /**
40 * Used internally - defines reusable UIHoverStyle's
41 */
42 static visionHoverStyleCache: {
43 [key: string]: UIHoverStyle;
44 };
45 /**
46 * Define reusable touch animations to use on views with touchAnimation defined or with enableGlobalTapAnimations on.
47 */
48 static animations: TouchAnimationOptions;
49 /**
50 * Native Touch handlers (iOS only) registered with the view through the TouchManager.
51 * The TouchManager uses this internally but makes public for other versatility if needed.
52 */
53 static touchHandlers: Array<{
54 view: View;
55 handler: any;
56 }>;
57 /**
58 * When using NativeScript AnimationDefinition's for touch animations this will contain any instances for finer grain control of starting/stopping under various circumstances.
59 * The TouchManager uses this internally but makes public for other versatility if needed.
60 */
61 static touchAnimationDefinitions: Array<{
62 view: View;
63 animation: Animation;
64 type: TouchAnimationTypes;
65 }>;
66 /**
67 * The TouchManager uses this internally.
68 * Adds touch animations to view based upon it's touchAnimation property or TouchManager.animations.
69 * @param view NativeScript view instance
70 */
71 static addAnimations(view: View): void;
72 static startAnimationForType(view: View, type: TouchAnimationTypes): void;
73 /**
74 * The TouchManager uses this internally.
75 * Adds visionOS hover styles to views based upon it's visionHoverStyle property
76 * @param view NativeScript view instance
77 */
78 static addHoverStyle(view: View): void;
79}
80export declare let TouchControlHandler: {
81 initWithOwner: (owner: WeakRef<View>) => any;
82};