Skip to content

Commit

Permalink
Explicitly mark lightbox worklets (#6038)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored Oct 31, 2024
1 parent 41452de commit d85dcc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,14 @@ const ImageItem = ({

const pinch = Gesture.Pinch()
.onStart(e => {
'worklet'
pinchOrigin.value = {
x: e.focalX - SCREEN.width / 2,
y: e.focalY - SCREEN.height / 2,
}
})
.onChange(e => {
'worklet'
if (!imageDimensions) {
return
}
Expand Down Expand Up @@ -179,6 +181,7 @@ const ImageItem = ({
}
})
.onEnd(() => {
'worklet'
// Commit just the pinch.
let t = createTransform()
prependPinch(
Expand All @@ -202,6 +205,7 @@ const ImageItem = ({
// Unlike .enabled(isScaled), this ensures that an initial pinch can turn into a pan midway:
.minPointers(isScaled ? 1 : 2)
.onChange(e => {
'worklet'
if (!imageDimensions) {
return
}
Expand All @@ -223,6 +227,7 @@ const ImageItem = ({
panTranslation.value = nextPanTranslation
})
.onEnd(() => {
'worklet'
// Commit just the pan.
let t = createTransform()
prependPan(t, panTranslation.value)
Expand All @@ -235,12 +240,14 @@ const ImageItem = ({
})

const singleTap = Gesture.Tap().onEnd(() => {
'worklet'
runOnJS(onTap)()
})

const doubleTap = Gesture.Tap()
.numberOfTaps(2)
.onEnd(e => {
'worklet'
if (!imageDimensions) {
return
}
Expand Down Expand Up @@ -287,9 +294,11 @@ const ImageItem = ({
.failOffsetX([-10, 10])
.maxPointers(1)
.onUpdate(e => {
'worklet'
dismissSwipeTranslateY.value = e.translationY
})
.onEnd(e => {
'worklet'
if (Math.abs(e.velocityY) > 1000) {
dismissSwipeTranslateY.value = withDecay({velocity: e.velocityY})
runOnJS(onRequestClose)()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,14 @@ const ImageItem = ({
}

const singleTap = Gesture.Tap().onEnd(() => {
'worklet'
runOnJS(onTap)()
})

const doubleTap = Gesture.Tap()
.numberOfTaps(2)
.onEnd(e => {
'worklet'
const {absoluteX, absoluteY} = e
runOnJS(handleDoubleTap)(absoluteX, absoluteY)
})
Expand Down

0 comments on commit d85dcc3

Please sign in to comment.