react-native-reanimated 4.1.3 → 4.1.4
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/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +24 -4
- package/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +7 -0
- package/android/build.gradle +1 -0
- package/lib/module/Colors.js +5 -8
- package/lib/module/Colors.js.map +1 -1
- package/lib/module/ConfigHelper.js +5 -3
- package/lib/module/ConfigHelper.js.map +1 -1
- package/lib/module/ReanimatedModule/NativeReanimated.js +1 -1
- package/lib/module/ReanimatedModule/NativeReanimated.js.map +1 -1
- package/lib/module/ReanimatedModule/js-reanimated/index.js.map +1 -1
- package/lib/module/animation/spring/spring.js +3 -4
- package/lib/module/animation/spring/spring.js.map +1 -1
- package/lib/module/animation/spring/springUtils.js +12 -0
- package/lib/module/animation/spring/springUtils.js.map +1 -1
- package/lib/module/common/logger.js +15 -11
- package/lib/module/common/logger.js.map +1 -1
- package/lib/module/common/processors/colors.js +1 -4
- package/lib/module/common/processors/colors.js.map +1 -1
- package/lib/module/createAnimatedComponent/AnimatedComponent.js +16 -5
- package/lib/module/createAnimatedComponent/AnimatedComponent.js.map +1 -1
- package/lib/module/createAnimatedComponent/InlinePropManager.js +13 -14
- package/lib/module/createAnimatedComponent/InlinePropManager.js.map +1 -1
- package/lib/module/css/index.js +1 -1
- package/lib/module/css/index.js.map +1 -1
- package/lib/module/css/native/normalization/common/settings.js +2 -12
- package/lib/module/css/native/normalization/common/settings.js.map +1 -1
- package/lib/module/css/native/style/config.js +2 -2
- package/lib/module/css/native/style/config.js.map +1 -1
- package/lib/module/css/utils/parsers.js +11 -0
- package/lib/module/css/utils/parsers.js.map +1 -1
- package/lib/module/css/utils/props.js +0 -5
- package/lib/module/css/utils/props.js.map +1 -1
- package/lib/module/css/web/managers/CSSAnimationsManager.js +68 -42
- package/lib/module/css/web/managers/CSSAnimationsManager.js.map +1 -1
- package/lib/module/fabricUtils.js +9 -11
- package/lib/module/fabricUtils.js.map +1 -1
- package/lib/module/hook/useAnimatedRef.js +12 -6
- package/lib/module/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/initializers.js +1 -3
- package/lib/module/initializers.js.map +1 -1
- package/lib/module/interpolateColor.js +75 -24
- package/lib/module/interpolateColor.js.map +1 -1
- package/lib/module/layoutReanimation/web/Easing.web.js +3 -0
- package/lib/module/layoutReanimation/web/Easing.web.js.map +1 -1
- package/lib/module/layoutReanimation/web/componentUtils.js +4 -3
- package/lib/module/layoutReanimation/web/componentUtils.js.map +1 -1
- package/lib/module/layoutReanimation/web/domUtils.js +1 -1
- package/lib/module/layoutReanimation/web/domUtils.js.map +1 -1
- package/lib/module/layoutReanimation/web/transition/Curved.web.js +1 -1
- package/lib/module/layoutReanimation/web/transition/Curved.web.js.map +1 -1
- package/lib/module/platform-specific/jsVersion.js +1 -1
- package/lib/typescript/Colors.d.ts +1 -1
- package/lib/typescript/Colors.d.ts.map +1 -1
- package/lib/typescript/ConfigHelper.d.ts.map +1 -1
- package/lib/typescript/ReanimatedModule/js-reanimated/index.d.ts +2 -1
- package/lib/typescript/ReanimatedModule/js-reanimated/index.d.ts.map +1 -1
- package/lib/typescript/animation/spring/spring.d.ts.map +1 -1
- package/lib/typescript/animation/spring/springUtils.d.ts +1 -0
- package/lib/typescript/animation/spring/springUtils.d.ts.map +1 -1
- package/lib/typescript/common/logger.d.ts +5 -5
- package/lib/typescript/common/logger.d.ts.map +1 -1
- package/lib/typescript/common/processors/colors.d.ts.map +1 -1
- package/lib/typescript/commonTypes.d.ts +1 -1
- package/lib/typescript/commonTypes.d.ts.map +1 -1
- package/lib/typescript/createAnimatedComponent/AnimatedComponent.d.ts.map +1 -1
- package/lib/typescript/createAnimatedComponent/InlinePropManager.d.ts.map +1 -1
- package/lib/typescript/css/index.d.ts +1 -1
- package/lib/typescript/css/index.d.ts.map +1 -1
- package/lib/typescript/css/native/normalization/common/settings.d.ts.map +1 -1
- package/lib/typescript/css/native/style/config.d.ts.map +1 -1
- package/lib/typescript/css/utils/parsers.d.ts +2 -1
- package/lib/typescript/css/utils/parsers.d.ts.map +1 -1
- package/lib/typescript/css/web/managers/CSSAnimationsManager.d.ts +2 -0
- package/lib/typescript/css/web/managers/CSSAnimationsManager.d.ts.map +1 -1
- package/lib/typescript/fabricUtils.d.ts.map +1 -1
- package/lib/typescript/hook/useAnimatedRef.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/initializers.d.ts.map +1 -1
- package/lib/typescript/interpolateColor.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/Easing.web.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/componentUtils.d.ts +1 -1
- package/lib/typescript/layoutReanimation/web/componentUtils.d.ts.map +1 -1
- package/lib/typescript/platform-specific/jsVersion.d.ts +1 -1
- package/package.json +1 -1
- package/src/Colors.ts +7 -10
- package/src/ConfigHelper.ts +9 -3
- package/src/ReanimatedModule/NativeReanimated.ts +1 -1
- package/src/ReanimatedModule/js-reanimated/index.ts +2 -1
- package/src/animation/spring/spring.ts +11 -6
- package/src/animation/spring/springUtils.ts +19 -0
- package/src/common/logger.ts +18 -11
- package/src/common/processors/colors.ts +1 -4
- package/src/commonTypes.ts +1 -1
- package/src/createAnimatedComponent/AnimatedComponent.tsx +17 -5
- package/src/createAnimatedComponent/InlinePropManager.ts +14 -15
- package/src/css/index.ts +1 -1
- package/src/css/native/normalization/common/settings.ts +2 -17
- package/src/css/native/style/config.ts +1 -1
- package/src/css/utils/parsers.ts +13 -1
- package/src/css/utils/props.ts +0 -8
- package/src/css/web/managers/CSSAnimationsManager.ts +85 -40
- package/src/fabricUtils.ts +12 -26
- package/src/hook/useAnimatedRef.ts +12 -9
- package/src/index.ts +1 -0
- package/src/initializers.ts +1 -9
- package/src/interpolateColor.ts +112 -43
- package/src/layoutReanimation/web/Easing.web.ts +4 -0
- package/src/layoutReanimation/web/componentUtils.ts +6 -4
- package/src/layoutReanimation/web/domUtils.ts +1 -1
- package/src/layoutReanimation/web/transition/Curved.web.ts +1 -1
- package/src/platform-specific/jsVersion.ts +1 -1
- package/src/privateGlobals.d.ts +1 -1
package/src/interpolateColor.ts
CHANGED
|
@@ -148,7 +148,7 @@ const interpolateColorsLAB = (
|
|
|
148
148
|
};
|
|
149
149
|
|
|
150
150
|
const _splitColorsIntoChannels = (
|
|
151
|
-
|
|
151
|
+
processedColors: readonly number[],
|
|
152
152
|
convFromRgb: (color: { r: number; g: number; b: number }) => {
|
|
153
153
|
ch1: number;
|
|
154
154
|
ch2: number;
|
|
@@ -166,21 +166,17 @@ const _splitColorsIntoChannels = (
|
|
|
166
166
|
const ch3: number[] = [];
|
|
167
167
|
const alpha: number[] = [];
|
|
168
168
|
|
|
169
|
-
for (
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
ch2.push(convertedColor.ch2);
|
|
181
|
-
ch3.push(convertedColor.ch3);
|
|
182
|
-
alpha.push(opacity(processedColor));
|
|
183
|
-
}
|
|
169
|
+
for (const processedColor of processedColors) {
|
|
170
|
+
const convertedColor = convFromRgb({
|
|
171
|
+
r: red(processedColor),
|
|
172
|
+
g: green(processedColor),
|
|
173
|
+
b: blue(processedColor),
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
ch1.push(convertedColor.ch1);
|
|
177
|
+
ch2.push(convertedColor.ch2);
|
|
178
|
+
ch3.push(convertedColor.ch3);
|
|
179
|
+
alpha.push(opacity(processedColor));
|
|
184
180
|
}
|
|
185
181
|
|
|
186
182
|
return {
|
|
@@ -199,11 +195,11 @@ export interface InterpolateRGB {
|
|
|
199
195
|
}
|
|
200
196
|
|
|
201
197
|
const getInterpolateRGB = (
|
|
202
|
-
|
|
198
|
+
processedColors: readonly number[]
|
|
203
199
|
): InterpolateRGB => {
|
|
204
200
|
'worklet';
|
|
205
201
|
const { ch1, ch2, ch3, alpha } = _splitColorsIntoChannels(
|
|
206
|
-
|
|
202
|
+
processedColors,
|
|
207
203
|
(color) => ({
|
|
208
204
|
ch1: color.r,
|
|
209
205
|
ch2: color.g,
|
|
@@ -227,17 +223,20 @@ export interface InterpolateHSV {
|
|
|
227
223
|
}
|
|
228
224
|
|
|
229
225
|
const getInterpolateHSV = (
|
|
230
|
-
|
|
226
|
+
processedColors: readonly number[]
|
|
231
227
|
): InterpolateHSV => {
|
|
232
228
|
'worklet';
|
|
233
|
-
const { ch1, ch2, ch3, alpha } = _splitColorsIntoChannels(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
229
|
+
const { ch1, ch2, ch3, alpha } = _splitColorsIntoChannels(
|
|
230
|
+
processedColors,
|
|
231
|
+
(color) => {
|
|
232
|
+
const hsvColor = RGBtoHSV(color.r, color.g, color.b);
|
|
233
|
+
return {
|
|
234
|
+
ch1: hsvColor.h,
|
|
235
|
+
ch2: hsvColor.s,
|
|
236
|
+
ch3: hsvColor.v,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
);
|
|
241
240
|
|
|
242
241
|
return {
|
|
243
242
|
h: ch1,
|
|
@@ -255,18 +254,20 @@ interface InterpolateLAB {
|
|
|
255
254
|
}
|
|
256
255
|
|
|
257
256
|
const getInterpolateLAB = (
|
|
258
|
-
|
|
257
|
+
processedColors: readonly number[]
|
|
259
258
|
): InterpolateLAB => {
|
|
260
259
|
'worklet';
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
260
|
+
const { ch1, ch2, ch3, alpha } = _splitColorsIntoChannels(
|
|
261
|
+
processedColors,
|
|
262
|
+
(color) => {
|
|
263
|
+
const labColor = culori.oklab.convert.fromRgb(color);
|
|
264
|
+
return {
|
|
265
|
+
ch1: labColor.l,
|
|
266
|
+
ch2: labColor.a,
|
|
267
|
+
ch3: labColor.b,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
);
|
|
270
271
|
|
|
271
272
|
return {
|
|
272
273
|
l: ch1,
|
|
@@ -276,6 +277,69 @@ const getInterpolateLAB = (
|
|
|
276
277
|
};
|
|
277
278
|
};
|
|
278
279
|
|
|
280
|
+
const TRANSPARENCY_MASK = 0x00ffffff; // AARRGGBB
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Processes color ranges to handle transparent color interpolation by replacing
|
|
284
|
+
* 'transparent' values with RGBA values that preserve the RGB channels from
|
|
285
|
+
* neighboring colors while setting alpha to 0.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* // Transparent between colors gets RGB from both neighbors
|
|
289
|
+
* ['red', 'transparent', 'blue'] → ['rgba(255, 0, 0, 1)', 'rgba(255, 0, 0, 0)', 'rgba(0, 0, 255, 0)', 'rgba(0, 0, 255, 1)']
|
|
290
|
+
*
|
|
291
|
+
* // Consecutive transparent values are consolidated if possible
|
|
292
|
+
* ['transparent', 'transparent', 'red'] → ['rgba(255, 0, 0, 0)', 'rgba(255, 0, 0, 1)']
|
|
293
|
+
*/
|
|
294
|
+
function processColorRanges(
|
|
295
|
+
inputRange: readonly number[],
|
|
296
|
+
outputRange: readonly (number | string)[]
|
|
297
|
+
): [readonly number[], readonly number[]] {
|
|
298
|
+
'worklet';
|
|
299
|
+
const processedInputRange: number[] = [];
|
|
300
|
+
const processedOutputRange: number[] = [];
|
|
301
|
+
let isPrevTransparent = false;
|
|
302
|
+
|
|
303
|
+
for (let i = 0; i < inputRange.length; i++) {
|
|
304
|
+
const color = outputRange[i];
|
|
305
|
+
const processedColor = processColor(color);
|
|
306
|
+
|
|
307
|
+
const isTransparent = color === 'transparent';
|
|
308
|
+
|
|
309
|
+
if (typeof processedColor === 'number') {
|
|
310
|
+
if (isPrevTransparent) {
|
|
311
|
+
// Ensure that we animate from the correct RGB values (the same as in the
|
|
312
|
+
// current color) with alpha 0 when animating from transparent to a color.
|
|
313
|
+
processedInputRange.push(inputRange[i - 1]);
|
|
314
|
+
processedOutputRange.push(processedColor & TRANSPARENCY_MASK);
|
|
315
|
+
}
|
|
316
|
+
// Add current color to the output range
|
|
317
|
+
processedInputRange.push(inputRange[i]);
|
|
318
|
+
processedOutputRange.push(processedColor);
|
|
319
|
+
} else if (!isPrevTransparent) {
|
|
320
|
+
// If the transparent color is encountered after the non-transparent color,
|
|
321
|
+
// then we add the last processed color with alpha 0 to the output range.
|
|
322
|
+
if (isTransparent && i > 0) {
|
|
323
|
+
const lastProcessedColor =
|
|
324
|
+
processedOutputRange[processedOutputRange.length - 1];
|
|
325
|
+
processedInputRange.push(inputRange[i]);
|
|
326
|
+
processedOutputRange.push(lastProcessedColor & TRANSPARENCY_MASK);
|
|
327
|
+
}
|
|
328
|
+
} else if (i === inputRange.length - 1 && !processedOutputRange.length) {
|
|
329
|
+
// If the end of the input range is reached, the previous color was transparent
|
|
330
|
+
// and the output range is empty, that means all colors were transparent,
|
|
331
|
+
// so we can add just 2 transparent colors to the output range.
|
|
332
|
+
const lastindex = inputRange.length - 1;
|
|
333
|
+
processedInputRange.push(inputRange[0], inputRange[lastindex]);
|
|
334
|
+
processedOutputRange.push(0, 0);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
isPrevTransparent = isTransparent;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return [processedInputRange, processedOutputRange];
|
|
341
|
+
}
|
|
342
|
+
|
|
279
343
|
/**
|
|
280
344
|
* Lets you map a value from a range of numbers to a range of colors using
|
|
281
345
|
* linear interpolation.
|
|
@@ -318,25 +382,30 @@ export function interpolateColor(
|
|
|
318
382
|
options: InterpolationOptions = {}
|
|
319
383
|
): string | number {
|
|
320
384
|
'worklet';
|
|
385
|
+
const [processedInputRange, processedOutputRange] = processColorRanges(
|
|
386
|
+
inputRange,
|
|
387
|
+
outputRange
|
|
388
|
+
);
|
|
389
|
+
|
|
321
390
|
if (colorSpace === 'HSV') {
|
|
322
391
|
return interpolateColorsHSV(
|
|
323
392
|
value,
|
|
324
|
-
|
|
325
|
-
getInterpolateHSV(
|
|
393
|
+
processedInputRange,
|
|
394
|
+
getInterpolateHSV(processedOutputRange),
|
|
326
395
|
options
|
|
327
396
|
);
|
|
328
397
|
} else if (colorSpace === 'RGB') {
|
|
329
398
|
return interpolateColorsRGB(
|
|
330
399
|
value,
|
|
331
|
-
|
|
332
|
-
getInterpolateRGB(
|
|
400
|
+
processedInputRange,
|
|
401
|
+
getInterpolateRGB(processedOutputRange),
|
|
333
402
|
options
|
|
334
403
|
);
|
|
335
404
|
} else if (colorSpace === 'LAB') {
|
|
336
405
|
return interpolateColorsLAB(
|
|
337
406
|
value,
|
|
338
|
-
|
|
339
|
-
getInterpolateLAB(
|
|
407
|
+
processedInputRange,
|
|
408
|
+
getInterpolateLAB(processedOutputRange),
|
|
340
409
|
options
|
|
341
410
|
);
|
|
342
411
|
}
|
|
@@ -29,6 +29,10 @@ export function getEasingByName(easingName: WebEasingsNames) {
|
|
|
29
29
|
export function maybeGetBezierEasing(
|
|
30
30
|
easing: EasingFunctionFactory
|
|
31
31
|
): null | string {
|
|
32
|
+
if (typeof easing === 'string') {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
if (!('factory' in easing)) {
|
|
33
37
|
return null;
|
|
34
38
|
}
|
|
@@ -190,7 +190,7 @@ export function setElementAnimation(
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
const maybeRemoveElement = () => {
|
|
193
|
-
if (element.
|
|
193
|
+
if (element.isDummy && parent?.contains(element)) {
|
|
194
194
|
element.removedAfterAnimation = true;
|
|
195
195
|
parent.removeChild(element);
|
|
196
196
|
}
|
|
@@ -318,16 +318,18 @@ function getElementScrollValue(element: HTMLElement): ScrollOffsets {
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
export function handleExitingAnimation(
|
|
321
|
-
element:
|
|
321
|
+
element: ReanimatedHTMLElement,
|
|
322
322
|
animationConfig: AnimationConfig
|
|
323
323
|
) {
|
|
324
324
|
const parent = element.offsetParent;
|
|
325
325
|
const dummy = element.cloneNode() as ReanimatedHTMLElement;
|
|
326
|
-
dummy.reanimatedDummy = true;
|
|
327
326
|
|
|
328
|
-
|
|
327
|
+
dummy.isDummy = true;
|
|
329
328
|
dummy.style.animationName = '';
|
|
330
329
|
|
|
330
|
+
element.dummyClone = dummy;
|
|
331
|
+
element.style.animationName = '';
|
|
332
|
+
|
|
331
333
|
// Moving elements in DOM resets their scroll positions
|
|
332
334
|
// so we memorize them here and restore after
|
|
333
335
|
const scrollPositions = new Map<Element, { top: number; left: number }>();
|
|
@@ -174,7 +174,7 @@ function findDescendantWithExitingAnimation(
|
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
if (node.
|
|
177
|
+
if (node.isDummy && node.removedAfterAnimation === undefined) {
|
|
178
178
|
reattachElementToAncestor(node, root);
|
|
179
179
|
}
|
|
180
180
|
|
package/src/privateGlobals.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ declare global {
|
|
|
56
56
|
| undefined;
|
|
57
57
|
var _frameCallbackRegistry: FrameCallbackRegistryUI;
|
|
58
58
|
var console: Console;
|
|
59
|
-
var __reanimatedLoggerConfig: LoggerConfigInternal;
|
|
59
|
+
var __reanimatedLoggerConfig: LoggerConfigInternal | undefined;
|
|
60
60
|
var __mapperRegistry: MapperRegistry;
|
|
61
61
|
var __sensorContainer: SensorContainer;
|
|
62
62
|
var LayoutAnimationsManager: LayoutAnimationsManager;
|