Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useState } from 'react';
import type { ViewStyle } from 'react-native';
import { StyleSheet, Text } from 'react-native';
import { StyleSheet, Text, View } from 'react-native';
import Animated, {
LinearTransition,
useAnimatedRef
Expand Down Expand Up @@ -46,6 +46,26 @@ function Example({ horizontal }: ExampleProps) {

const renderItem = useCallback<SortableGridRenderItem<string>>(
({ item }) => {
if (IS_WEB) {
return (
// The height/width of the outermost item container must be changed immediately
// to the new final value so we set it here as well and change without animation
<View style={[{ [dimension]: collapsed ? sizes.lg : sizes.xxxl }]}>
<Animated.View
style={[
styles.card,
{
[dimension]: collapsed ? sizes.lg : sizes.xxxl,
// Uses Reanimated 4 CSS transitions
transitionDuration: 300
}
]}>
<Text style={styles.text}>{item}</Text>
</Animated.View>
</View>
);
}

const layoutTransition = LinearTransition.delay(collapsed ? 0 : 50);

return (
Expand Down
19 changes: 10 additions & 9 deletions example/app/src/examples/navigation/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,22 @@ const routes: Routes = {
}
}
},
...(!IS_WEB && {
Miscellaneous: {
name: 'Miscellaneous',
routes: {

Miscellaneous: {
name: 'Miscellaneous',
routes: {
...(!IS_WEB && {
StaggerAnimation: {
Component: SortableGrid.miscellaneous.StaggerAnimationExample,
name: 'Stagger Animation'
},
CollapsibleItems: {
Component: SortableGrid.miscellaneous.CollapsibleItemsExample,
name: 'Collapsible Items'
}
}),
CollapsibleItems: {
Component: SortableGrid.miscellaneous.CollapsibleItemsExample,
name: 'Collapsible Items'
}
}
}),
},
Tests: {
name: 'Test examples',
routes: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ const { GridLayoutProvider, useGridLayoutContext } = createProvider(
// GRID LAYOUT UPDATER
useAnimatedReaction(
() => ({
_: layoutRequestId.value, // Helper to force layout re-calculation
gaps: {
cross: crossGap.value,
main: mainGap.value
Expand All @@ -167,7 +166,8 @@ const { GridLayoutProvider, useGridLayoutContext } = createProvider(
isVertical,
itemHeights: itemHeights.value,
itemWidths: itemWidths.value,
numGroups
numGroups,
requestId: layoutRequestId.value // Helper to force layout re-calculation
}),
(props, prevProps) => {
const adaptedProps: GridLayoutProps =
Expand Down Expand Up @@ -198,7 +198,7 @@ const { GridLayoutProvider, useGridLayoutContext } = createProvider(

if (adaptedProps.shouldAnimateLayout !== undefined) {
shouldAnimateLayout.value = adaptedProps.shouldAnimateLayout;
} else if (IS_WEB) {
} else if (IS_WEB && props.requestId === prevProps?.requestId) {
updateShouldAnimateWeb?.(adaptedProps, prevProps);
} else {
shouldAnimateLayout.value = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ function AutoScrollUpdater({

const distance = velocity * (cappedElapsedTime / 1000);

console.log('frameCallbackFunction', distance, ctx.progress);
scrollBy(distance, animateScrollTo);
},
[
Expand Down
Loading