Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
}
}, [layout])
const onClose = useRef(() => {
console.tron.debug('close')
})
const bottomSheetRef = useRef(null)
const callbackNode = useRef(new Animated.Value(1))
const callbackNode1 = useRef(new Animated.Value(1))
Animated.useCode(
Animated.onChange(
callbackNode.current,
Animated.block([
Animated.cond(
Animated.greaterOrEq(callbackNode.current, 1),
Animated.set(
callbackNode1.current,
Animated.add(Animated.multiply(-10, callbackNode.current)),
),
/* Animated.call([], () => {
* onClose.current && onClose.current();
* }), */
),
]),
),
[onClose],
)
const bs = useRef(null)
const newLocal = {
inputRange: [0.9, 1],
outputRange: [0, 1],
Animated.useCode(() => {
// scrollDiff is the amount the header has scrolled since last time this code ran
const scrollDiff = Animated.diff(scrollOffsetY)
const headerIsNotFullyUp = Animated.neq(headerOffsetY, negative(headerHeight))
const nearTheTop = Animated.lessOrEq(scrollOffsetY, headerHeight)
const amountScrolledUpward = new Animated.Value(0)
const upwardScrollThresholdBreached = Animated.greaterOrEq(amountScrolledUpward, 400)
// this is the code which actually performs the update to headerOffsetY, according to which direction
// the scrolling is going
const updateHeaderOffset = Animated.cond(
Animated.greaterThan(scrollDiff, 0),
[
// y offset got bigger so scrolling down (content travels up the screen)
// move the header up (hide it) unconditionally
Animated.set(amountScrolledUpward, 0),
Animated.set(headerOffsetY, Animated.max(negative(headerHeight), Animated.sub(headerOffsetY, scrollDiff))),
],
[
// y offset got smaller so scrolling up (content travels down the screen)
// if velocity is high enough or we're already moving the header up or we're near the top of the scroll view
// then move the header down (show it)
Animated.set(amountScrolledUpward, Animated.add(amountScrolledUpward, Animated.abs(scrollDiff))),
const isInRegion = (
x: Animated.Node,
y: Animated.Node,
region: { x: number; y: number }
) => {
return and(
and(greaterOrEq(x, region.x), lessOrEq(x, region.x + BUTTON_SIZE)),
and(greaterOrEq(y, region.y), lessOrEq(y, region.y + BUTTON_SIZE))
);
};
tabs.map((tab, i) =>
cond(
i === tabs.length - 1
? greaterOrEq(y, tab.anchor)
: and(
greaterOrEq(y, tab.anchor),
lessOrEq(y, tabs[i + 1].anchor)
),
set(index, i)
)
)
);
}
if (mathType === 'reanimated') {
return Animated.greaterThan(left, right);
}
return Number((left as number) > (right as number));
}
if (tree.token.value === '>=') {
if (Array.isArray(left) || Array.isArray(right)) {
throw new InvalidExpressionError(
`${logPrefix} Cannot use operator ">=" on array`
);
}
if (mathType === 'reanimated') {
return Animated.greaterOrEq(left, right);
}
return Number((left as number) >= (right as number));
}
if (tree.token.value === '<=') {
if (Array.isArray(left) || Array.isArray(right)) {
throw new InvalidExpressionError(
`${logPrefix} Cannot use operator "<=" on array`
);
}
if (mathType === 'reanimated') {
return Animated.lessOrEq(left, right);
}
return Number((left as number) <= (right as number));
}
tabs.map((tab, i) =>
cond(
i === tabs.length - 1
? greaterOrEq(y, tab.anchor)
: and(
greaterOrEq(y, tab.anchor),
lessOrEq(y, tabs[i + 1].anchor)
),
set(index, i)
)
)