@hema-to/regl-scatterplot 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1110 -0
- package/dist/regl-scatterplot.esm.d.ts +126 -0
- package/dist/regl-scatterplot.esm.js +9962 -0
- package/dist/regl-scatterplot.js +9385 -0
- package/dist/regl-scatterplot.min.js +8 -0
- package/dist/types.d.ts +306 -0
- package/package.json +100 -0
- package/src/bg.fs +13 -0
- package/src/bg.vs +16 -0
- package/src/constants.js +189 -0
- package/src/index.js +4654 -0
- package/src/kdbush-class.js +369 -0
- package/src/kdbush-worker.js +20 -0
- package/src/kdbush.js +69 -0
- package/src/lasso-manager/constants.js +7 -0
- package/src/lasso-manager/create-long-press-animations.js +257 -0
- package/src/lasso-manager/create-long-press-elements.js +68 -0
- package/src/lasso-manager/index.js +781 -0
- package/src/lasso-manager/utils.js +40 -0
- package/src/point-simple.fs +10 -0
- package/src/point-update.fs +21 -0
- package/src/point-update.vs +13 -0
- package/src/point.fs +22 -0
- package/src/point.vs +124 -0
- package/src/renderer.js +252 -0
- package/src/spline-curve-worker.js +271 -0
- package/src/spline-curve.js +23 -0
- package/src/types.d.ts +306 -0
- package/src/utils.js +598 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_LASSO_LONG_PRESS_AFTER_EFFECT_TIME,
|
|
3
|
+
DEFAULT_LASSO_LONG_PRESS_EFFECT_DELAY,
|
|
4
|
+
DEFAULT_LASSO_LONG_PRESS_REVERT_EFFECT_TIME,
|
|
5
|
+
DEFAULT_LASSO_LONG_PRESS_TIME,
|
|
6
|
+
} from '../constants.js';
|
|
7
|
+
|
|
8
|
+
const getInTime = (p, time, extraTime) => (1 - p) * time + extraTime;
|
|
9
|
+
|
|
10
|
+
const getMainInAnimation = (t, d) =>
|
|
11
|
+
`${t}ms ease-out mainIn ${d}ms 1 normal forwards`;
|
|
12
|
+
|
|
13
|
+
const getEffectInAnimation = (t, d) =>
|
|
14
|
+
`${t}ms ease-out effectIn ${d}ms 1 normal forwards`;
|
|
15
|
+
|
|
16
|
+
const getCircleLeftInAnimation = (t, d) =>
|
|
17
|
+
`${t}ms linear leftSpinIn ${d}ms 1 normal forwards`;
|
|
18
|
+
|
|
19
|
+
const getCircleRightInAnimation = (t, d) =>
|
|
20
|
+
`${t}ms linear rightSpinIn ${d}ms 1 normal forwards`;
|
|
21
|
+
|
|
22
|
+
const getCircleInAnimation = (t, d) =>
|
|
23
|
+
`${t}ms linear circleIn ${d}ms 1 normal forwards`;
|
|
24
|
+
|
|
25
|
+
const getMainIn = (mainEffectPercent, currentColor, targetColor) => `
|
|
26
|
+
@keyframes mainIn {
|
|
27
|
+
0% {
|
|
28
|
+
color: ${currentColor};
|
|
29
|
+
opacity: 0;
|
|
30
|
+
}
|
|
31
|
+
0%, ${mainEffectPercent}% {
|
|
32
|
+
color: ${currentColor};
|
|
33
|
+
opacity: 1;
|
|
34
|
+
}
|
|
35
|
+
100% {
|
|
36
|
+
color: ${targetColor};
|
|
37
|
+
opacity: 0.8;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
const getEffectIn = (mainEffectPercent, afterEffectPercent, opacity, scale) => `
|
|
43
|
+
@keyframes effectIn {
|
|
44
|
+
0%, ${mainEffectPercent}% {
|
|
45
|
+
opacity: ${opacity};
|
|
46
|
+
transform: scale(${scale});
|
|
47
|
+
}
|
|
48
|
+
${afterEffectPercent}% {
|
|
49
|
+
opacity: 0.66;
|
|
50
|
+
transform: scale(1.5);
|
|
51
|
+
}
|
|
52
|
+
99% {
|
|
53
|
+
opacity: 0;
|
|
54
|
+
transform: scale(2);
|
|
55
|
+
}
|
|
56
|
+
100% {
|
|
57
|
+
opacity: 0;
|
|
58
|
+
transform: scale(0);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const getCircleIn = (halfMainEffectPercent, clipPath, opacity) => `
|
|
64
|
+
@keyframes circleIn {
|
|
65
|
+
0% {
|
|
66
|
+
clip-path: ${clipPath};
|
|
67
|
+
opacity: ${opacity};
|
|
68
|
+
}
|
|
69
|
+
${halfMainEffectPercent}% {
|
|
70
|
+
clip-path: ${clipPath};
|
|
71
|
+
opacity: 1;
|
|
72
|
+
}
|
|
73
|
+
${halfMainEffectPercent + 0.01}%, 100% {
|
|
74
|
+
clip-path: inset(0);
|
|
75
|
+
opacity: 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
const getCircleLeftIn = (mainEffectPercent, angle) => `
|
|
81
|
+
@keyframes leftSpinIn {
|
|
82
|
+
0% {
|
|
83
|
+
transform: rotate(${angle}deg);
|
|
84
|
+
}
|
|
85
|
+
${mainEffectPercent}%, 100% {
|
|
86
|
+
transform: rotate(360deg);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
const getCircleRightIn = (halfMainEffectPercent, angle) => `
|
|
92
|
+
@keyframes rightSpinIn {
|
|
93
|
+
0% {
|
|
94
|
+
transform: rotate(${angle}deg);
|
|
95
|
+
}
|
|
96
|
+
${halfMainEffectPercent}%, 100% {
|
|
97
|
+
transform: rotate(180deg);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
export const createLongPressInAnimations = ({
|
|
103
|
+
time = DEFAULT_LASSO_LONG_PRESS_TIME,
|
|
104
|
+
extraTime = DEFAULT_LASSO_LONG_PRESS_AFTER_EFFECT_TIME,
|
|
105
|
+
delay = DEFAULT_LASSO_LONG_PRESS_EFFECT_DELAY,
|
|
106
|
+
currentColor,
|
|
107
|
+
targetColor,
|
|
108
|
+
effectOpacity,
|
|
109
|
+
effectScale,
|
|
110
|
+
circleLeftRotation,
|
|
111
|
+
circleRightRotation,
|
|
112
|
+
circleClipPath,
|
|
113
|
+
circleOpacity,
|
|
114
|
+
}) => {
|
|
115
|
+
const p = circleLeftRotation / 360;
|
|
116
|
+
const actualTime = getInTime(p, time, extraTime);
|
|
117
|
+
const longPressPercent = Math.round((((1 - p) * time) / actualTime) * 100);
|
|
118
|
+
const halfLongPressPercent = Math.round(longPressPercent / 2);
|
|
119
|
+
const afterEffectPercent = longPressPercent + (100 - longPressPercent) / 4;
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
rules: {
|
|
123
|
+
main: getMainIn(longPressPercent, currentColor, targetColor),
|
|
124
|
+
effect: getEffectIn(
|
|
125
|
+
longPressPercent,
|
|
126
|
+
afterEffectPercent,
|
|
127
|
+
effectOpacity,
|
|
128
|
+
effectScale,
|
|
129
|
+
),
|
|
130
|
+
circleRight: getCircleRightIn(halfLongPressPercent, circleRightRotation),
|
|
131
|
+
circleLeft: getCircleLeftIn(longPressPercent, circleLeftRotation),
|
|
132
|
+
circle: getCircleIn(halfLongPressPercent, circleClipPath, circleOpacity),
|
|
133
|
+
},
|
|
134
|
+
names: {
|
|
135
|
+
main: getMainInAnimation(actualTime, delay),
|
|
136
|
+
effect: getEffectInAnimation(actualTime, delay),
|
|
137
|
+
circleLeft: getCircleLeftInAnimation(actualTime, delay),
|
|
138
|
+
circleRight: getCircleRightInAnimation(actualTime, delay),
|
|
139
|
+
circle: getCircleInAnimation(actualTime, delay),
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const getMainOutAnimation = (t) => `${t}ms linear mainOut 0s 1 normal forwards`;
|
|
145
|
+
|
|
146
|
+
const getEffectOutAnimation = (t) =>
|
|
147
|
+
`${t}ms linear effectOut 0s 1 normal forwards`;
|
|
148
|
+
|
|
149
|
+
const getCircleLeftOutAnimation = (t) =>
|
|
150
|
+
`${t}ms linear leftSpinOut 0s 1 normal forwards`;
|
|
151
|
+
|
|
152
|
+
const getCircleRightOutAnimation = (t) =>
|
|
153
|
+
`${t}ms linear rightSpinOut 0s 1 normal forwards`;
|
|
154
|
+
|
|
155
|
+
const getCircleOutAnimation = (t) =>
|
|
156
|
+
`${t}ms linear circleOut 0s 1 normal forwards`;
|
|
157
|
+
|
|
158
|
+
const getMainOut = (currentColor, targetColor) => `
|
|
159
|
+
@keyframes mainOut {
|
|
160
|
+
0% {
|
|
161
|
+
color: ${currentColor};
|
|
162
|
+
}
|
|
163
|
+
100% {
|
|
164
|
+
color: ${targetColor};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
`;
|
|
168
|
+
|
|
169
|
+
const getEffectOut = (opacity, scale) => `
|
|
170
|
+
@keyframes effectOut {
|
|
171
|
+
0% {
|
|
172
|
+
opacity: ${opacity};
|
|
173
|
+
transform: scale(${scale});
|
|
174
|
+
}
|
|
175
|
+
99% {
|
|
176
|
+
opacity: 0;
|
|
177
|
+
transform: scale(${scale + 0.5});
|
|
178
|
+
}
|
|
179
|
+
100% {
|
|
180
|
+
opacity: 0;
|
|
181
|
+
transform: scale(0);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
`;
|
|
185
|
+
|
|
186
|
+
const getCircleRightOut = (halfEffectPercent, angle) => `
|
|
187
|
+
@keyframes rightSpinOut {
|
|
188
|
+
0%, ${halfEffectPercent}% {
|
|
189
|
+
transform: rotate(${angle}deg);
|
|
190
|
+
}
|
|
191
|
+
100% {
|
|
192
|
+
transform: rotate(0deg);
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
195
|
+
|
|
196
|
+
const getCircleLeftOut = (angle) => `
|
|
197
|
+
@keyframes leftSpinOut {
|
|
198
|
+
0% {
|
|
199
|
+
transform: rotate(${angle}deg);
|
|
200
|
+
}
|
|
201
|
+
100% {
|
|
202
|
+
transform: rotate(0deg);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
`;
|
|
206
|
+
|
|
207
|
+
const getCircleOut = (halfEffectPercent, clipPath, opacity) => `
|
|
208
|
+
@keyframes circleOut {
|
|
209
|
+
0%, ${halfEffectPercent}% {
|
|
210
|
+
clip-path: ${clipPath};
|
|
211
|
+
opacity: ${opacity};
|
|
212
|
+
}
|
|
213
|
+
${halfEffectPercent + 0.01}% {
|
|
214
|
+
clip-path: inset(0 0 0 50%);
|
|
215
|
+
opacity: ${opacity};
|
|
216
|
+
}
|
|
217
|
+
100% {
|
|
218
|
+
clip-path: inset(0 0 0 50%);
|
|
219
|
+
opacity: 0;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
`;
|
|
223
|
+
|
|
224
|
+
export const createLongPressOutAnimations = ({
|
|
225
|
+
time = DEFAULT_LASSO_LONG_PRESS_REVERT_EFFECT_TIME,
|
|
226
|
+
currentColor,
|
|
227
|
+
targetColor,
|
|
228
|
+
effectOpacity,
|
|
229
|
+
effectScale,
|
|
230
|
+
circleLeftRotation,
|
|
231
|
+
circleRightRotation,
|
|
232
|
+
circleClipPath,
|
|
233
|
+
circleOpacity,
|
|
234
|
+
}) => {
|
|
235
|
+
const p = circleLeftRotation / 360;
|
|
236
|
+
const actualTime = p * time;
|
|
237
|
+
const rotatedPercent = Math.min(100, p * 100);
|
|
238
|
+
const halfPercent =
|
|
239
|
+
rotatedPercent > 50 ? Math.round((1 - 50 / rotatedPercent) * 100) : 0;
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
rules: {
|
|
243
|
+
main: getMainOut(currentColor, targetColor),
|
|
244
|
+
effect: getEffectOut(effectOpacity, effectScale),
|
|
245
|
+
circleRight: getCircleRightOut(halfPercent, circleRightRotation),
|
|
246
|
+
circleLeft: getCircleLeftOut(circleLeftRotation),
|
|
247
|
+
circle: getCircleOut(halfPercent, circleClipPath, circleOpacity),
|
|
248
|
+
},
|
|
249
|
+
names: {
|
|
250
|
+
main: getMainOutAnimation(actualTime),
|
|
251
|
+
effect: getEffectOutAnimation(actualTime),
|
|
252
|
+
circleRight: getCircleLeftOutAnimation(actualTime),
|
|
253
|
+
circleLeft: getCircleRightOutAnimation(actualTime),
|
|
254
|
+
circle: getCircleOutAnimation(actualTime),
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export const createLongPressElements = () => {
|
|
2
|
+
const longPress = document.createElement('div');
|
|
3
|
+
const longPressId =
|
|
4
|
+
Math.random().toString(36).substring(2, 5) +
|
|
5
|
+
Math.random().toString(36).substring(2, 5);
|
|
6
|
+
longPress.id = `lasso-long-press-${longPressId}`;
|
|
7
|
+
longPress.style.position = 'fixed';
|
|
8
|
+
longPress.style.width = '1.25rem';
|
|
9
|
+
longPress.style.height = '1.25rem';
|
|
10
|
+
longPress.style.pointerEvents = 'none';
|
|
11
|
+
longPress.style.transform = 'translate(-50%,-50%)';
|
|
12
|
+
|
|
13
|
+
const longPressCircle = document.createElement('div');
|
|
14
|
+
longPressCircle.style.position = 'absolute';
|
|
15
|
+
longPressCircle.style.top = 0;
|
|
16
|
+
longPressCircle.style.left = 0;
|
|
17
|
+
longPressCircle.style.width = '1.25rem';
|
|
18
|
+
longPressCircle.style.height = '1.25rem';
|
|
19
|
+
longPressCircle.style.clipPath = 'inset(0px 0px 0px 50%)';
|
|
20
|
+
longPressCircle.style.opacity = 0;
|
|
21
|
+
longPress.appendChild(longPressCircle);
|
|
22
|
+
|
|
23
|
+
const longPressCircleLeft = document.createElement('div');
|
|
24
|
+
longPressCircleLeft.style.position = 'absolute';
|
|
25
|
+
longPressCircleLeft.style.top = 0;
|
|
26
|
+
longPressCircleLeft.style.left = 0;
|
|
27
|
+
longPressCircleLeft.style.width = '0.8rem';
|
|
28
|
+
longPressCircleLeft.style.height = '0.8rem';
|
|
29
|
+
longPressCircleLeft.style.border = '0.2rem solid currentcolor';
|
|
30
|
+
longPressCircleLeft.style.borderRadius = '0.8rem';
|
|
31
|
+
longPressCircleLeft.style.clipPath = 'inset(0px 50% 0px 0px)';
|
|
32
|
+
longPressCircleLeft.style.transform = 'rotate(0deg)';
|
|
33
|
+
longPressCircle.appendChild(longPressCircleLeft);
|
|
34
|
+
|
|
35
|
+
const longPressCircleRight = document.createElement('div');
|
|
36
|
+
longPressCircleRight.style.position = 'absolute';
|
|
37
|
+
longPressCircleRight.style.top = 0;
|
|
38
|
+
longPressCircleRight.style.left = 0;
|
|
39
|
+
longPressCircleRight.style.width = '0.8rem';
|
|
40
|
+
longPressCircleRight.style.height = '0.8rem';
|
|
41
|
+
longPressCircleRight.style.border = '0.2rem solid currentcolor';
|
|
42
|
+
longPressCircleRight.style.borderRadius = '0.8rem';
|
|
43
|
+
longPressCircleRight.style.clipPath = 'inset(0px 50% 0px 0px)';
|
|
44
|
+
longPressCircleRight.style.transform = 'rotate(0deg)';
|
|
45
|
+
longPressCircle.appendChild(longPressCircleRight);
|
|
46
|
+
|
|
47
|
+
const longPressEffect = document.createElement('div');
|
|
48
|
+
longPressEffect.style.position = 'absolute';
|
|
49
|
+
longPressEffect.style.top = 0;
|
|
50
|
+
longPressEffect.style.left = 0;
|
|
51
|
+
longPressEffect.style.width = '1.25rem';
|
|
52
|
+
longPressEffect.style.height = '1.25rem';
|
|
53
|
+
longPressEffect.style.borderRadius = '1.25rem';
|
|
54
|
+
longPressEffect.style.background = 'currentcolor';
|
|
55
|
+
longPressEffect.style.transform = 'scale(0)';
|
|
56
|
+
longPressEffect.style.opacity = 0;
|
|
57
|
+
longPress.appendChild(longPressEffect);
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
longPress,
|
|
61
|
+
longPressCircle,
|
|
62
|
+
longPressCircleLeft,
|
|
63
|
+
longPressCircleRight,
|
|
64
|
+
longPressEffect,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default createLongPressElements;
|