Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const splitProgressProc = Animated.proc((normalizedProgress, isFocused) =>
Animated.cond(
Animated.eq(isFocused, 1),
// Focused screen
Animated.cond(
Animated.greaterThan(normalizedProgress, 0.5),
Animated.multiply(2, Animated.sub(normalizedProgress, 0.5)),
0,
),
// Screen we are moving from
Animated.cond(
Animated.lessThan(normalizedProgress, 0.5),
Animated.multiply(normalizedProgress, 2),
1,
),
),
);
width: Dimensions.get('window').width,
};
@observer
export default class WeekTabView extends React.Component {
// tslint:disable max-line-length
private tabBar: any;
private tabBarUpdated: boolean = false;
private panX = new Animated.Value(0);
private scrollY = new Reanimated.Value(0);
private scrollEndDragVelocity = new Reanimated.Value(10000000);
private snapOffset = new Reanimated.Value(0);
private clock = new Reanimated.Clock();
private diffClampNode = Reanimated.diffClamp(Reanimated.add(this.scrollY, this.snapOffset), 0, NAVBAR_HEIGHT);
private inverseDiffClampNode = Reanimated.multiply(this.diffClampNode, -1);
private snapPoint = Reanimated.cond(Reanimated.lessThan(this.diffClampNode, NAVBAR_HEIGHT / 2), 0, -NAVBAR_HEIGHT);
private animatedNavBarTranslateY = Reanimated.cond(
Reanimated.neq(this.scrollEndDragVelocity, 10000000),
runScrollEndSpring({
diffClampNode: this.diffClampNode,
clock: this.clock,
from: this.inverseDiffClampNode,
velocity: 0,
toValue: this.snapPoint,
scrollEndDragVelocity: this.scrollEndDragVelocity,
snapOffset: this.snapOffset,
height: NAVBAR_HEIGHT,
}),
this.inverseDiffClampNode,
);
const splitProgressProc = Animated.proc((normalizedProgress, isFocused) =>
Animated.cond(
Animated.eq(isFocused, 1),
// Focused screen
Animated.cond(
Animated.greaterThan(normalizedProgress, 0.5),
Animated.multiply(2, Animated.sub(normalizedProgress, 0.5)),
0,
),
// Screen we are moving from
Animated.cond(
Animated.lessThan(normalizedProgress, 0.5),
Animated.multiply(normalizedProgress, 2),
1,
),
),
);
const inViewport = (
index: Animated.Node,
translateY: Animated.Node,
goingUp: Animated.Node<0 | 1>
) => {
const y = multiply(add(index, not(goingUp)), ITEM_HEIGHT);
const translate = multiply(translateY, -1);
return and(
greaterOrEq(y, translate),
lessOrEq(y, add(translate, CONTENT_HEIGHT))
);
};
const negative = (node: Animated.Node) => Animated.multiply(-1, node)
);
}
if (mathType === 'reanimated') {
return Animated.pow(left, right);
}
return (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.multiply(left, right);
}
return (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.modulo(left, right);
}
return (left as number) % (right as number);
}
(scrollAmount: Animated.Node, maxScrollDistance: number) =>
Animated.multiply(
Platform.OS === 'android' && I18nManager.isRTL
? Animated.sub(maxScrollDistance, scrollAmount)
: scrollAmount,
I18nManager.isRTL ? 1 : -1
)
);