Skip to content

Incubator.Slider - fix onSeek functions #2955

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

Merged
merged 2 commits into from
Feb 18, 2024
Merged
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
19 changes: 16 additions & 3 deletions src/incubator/Slider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,20 @@ const Slider = React.memo((props: Props) => {
}
}, []);

const _onSeekStart = () => {
'worklet';
if (onSeekStart) {
runOnJS(onSeekStart)();
}
};

const _onSeekEnd = () => {
'worklet';
if (onSeekEnd) {
runOnJS(onSeekEnd)();
}
};

// @ts-expect-error should be fixed in version 3.5 (https://github.com/software-mansion/react-native-reanimated/pull/4881)
const trackAnimatedStyles = useAnimatedStyle(() => {
if (useRange) {
Expand All @@ -360,7 +374,6 @@ const Slider = React.memo((props: Props) => {
});

/** renders */

const renderThumb = (type: ThumbType) => {
return (
<Thumb
Expand All @@ -369,8 +382,8 @@ const Slider = React.memo((props: Props) => {
offset={type === ThumbType.DEFAULT ? defaultThumbOffset : rangeThumbOffset}
gap={rangeGap}
secondary={type !== ThumbType.DEFAULT}
onSeekStart={onSeekStart}
onSeekEnd={onSeekEnd}
onSeekStart={_onSeekStart}
onSeekEnd={_onSeekEnd}
shouldDisableRTL={shouldDisableRTL}
disabled={disabled}
disableActiveStyling={disableActiveStyling}
Expand Down