aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/trails/SpringUtils.ts
blob: 5feb1628a54244fa85ecccc85f32a40f017796d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { PresEffect, PresMovement } from './PresEnums';

// the type of slide effect timing (spring-driven)
export enum SpringType {
    DEFAULT = 'default',
    GENTLE = 'gentle',
    BOUNCY = 'bouncy',
    CUSTOM = 'custom',
    QUICK = 'quick',
}

// settings that control slide effect spring settings
export interface SpringSettings {
    type: SpringType;
    stiffness: number;
    damping: number;
    mass: number;
}

export const easeItems = [
    {
        text: 'Ease',
        val: 'ease',
    },
    {
        text: 'Ease In',
        val: 'ease-in',
    },
    {
        text: 'Ease Out',
        val: 'ease-out',
    },
    {
        text: 'Ease In Out',
        val: 'ease-in-out',
    },
    {
        text: 'Linear',
        val: 'linear',
    },
    {
        text: 'Custom',
        val: 'custom',
    },
];

export const movementItems = [
    { text: 'None', val: PresMovement.None },
    { text: 'Center', val: PresMovement.Center },
    { text: 'Zoom', val: PresMovement.Zoom },
    { text: 'Pan', val: PresMovement.Pan },
    { text: 'Jump', val: PresMovement.Jump },
];

export const effectItems = Object.values(PresEffect)
    .filter(v => isNaN(Number(v)))
    .map(effect => ({
        text: effect,
        val: effect,
    }));

export const effectTimings = [
    { text: 'Default', val: SpringType.DEFAULT },
    {
        text: 'Gentle',
        val: SpringType.GENTLE,
    },
    {
        text: 'Quick',
        val: SpringType.QUICK,
    },
    {
        text: 'Bouncy',
        val: SpringType.BOUNCY,
    },
    {
        text: 'Custom',
        val: SpringType.CUSTOM,
    },
];

// Maps spring names to spring parameters
export const springMappings: {
    [key: string]: { stiffness: number; damping: number; mass: number };
} = {
    default: {
        stiffness: 600,
        damping: 15,
        mass: 1,
    },
    gentle: {
        stiffness: 100,
        damping: 15,
        mass: 1,
    },
    quick: {
        stiffness: 300,
        damping: 20,
        mass: 1,
    },
    bouncy: {
        stiffness: 600,
        damping: 15,
        mass: 1,
    },
    custom: {
        stiffness: 100,
        damping: 10,
        mass: 1,
    },
};