-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Rewrite BokehExample into transforms in the example app #8415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Oskar Pawica <[email protected]>
useSharedValue, | ||
withRepeat, | ||
withTiming, | ||
type WithTimingConfig, |
There was a problem hiding this comment.
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 }; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
function getBokehCircleParams(): CircleProps { | |
function makeRandomCircleParams(): CircleProps { |
left: 0, | ||
top: 0, |
There was a problem hiding this comment.
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
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; |
There was a problem hiding this comment.
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?
size: number; | ||
opacity: number; |
There was a problem hiding this comment.
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.
Summary
This PR optimizes the Bokeh example in the example app, by rewriting:
withRepeat
instead of JS intervalsCircle
component for potential reusability in some other examplestransform
property instead ofleft
andtop
directlyTest plan