Skip to content

Conversation

pawicao
Copy link
Collaborator

@pawicao pawicao commented Oct 17, 2025

Summary

This PR optimizes the Bokeh example in the example app, by rewriting:

  • the animation logic to use withRepeat instead of JS intervals
  • introducing props-based Circle component for potential reusability in some other examples
  • animatins the transform property instead of left and top directly

Test plan

@pawicao pawicao requested a review from tomekzaw October 17, 2025 14:47
useSharedValue,
withRepeat,
withTiming,
type WithTimingConfig,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs to be moved to a separate import as we have an ESLint rule that forbids mixed imports.

hue.value = withTiming(hue.value + randBetween(0, 100), config);
};
const numberOfReps = shouldReduceMotion ? 1 : -1;
const config: WithTimingConfig = { duration, easing: Easing.linear };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to pass WithTimingConfig type here?

return min + Math.random() * (max - min);
}

function getBokehCircleParams(): CircleProps {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use make to convey that a new instance of something is created on each function call.

Suggested change
function getBokehCircleParams(): CircleProps {
function makeRandomCircleParams(): CircleProps {

Comment on lines +153 to +154
left: 0,
top: 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this is not necessary

Suggested change
left: 0,
top: 0,

top.value = withTiming(top.value + randBetween(-100, 100), config);
hue.value = withTiming(hue.value + randBetween(0, 100), config);
};
const numberOfReps = shouldReduceMotion ? 1 : -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why it was done this way but maybe let's rethink the expected behavior when the reduced motion setting is enabled?

Comment on lines +23 to +24
size: number;
opacity: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth moving these two to the top to separate the "static" props of circles from the ones that have "start" and "end" variants, just for the sake of readability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants