Browse Source

round scroll event offset

pull/8/head
Tim Glasgow 2 years ago
parent
commit
248d209dd6
  1. 5
      squarenotsquare/src/components/ScrollingPicker.js

5
squarenotsquare/src/components/ScrollingPicker.js

@ -14,9 +14,10 @@ function ScrollingPicker(props) {
const scrollX = useRef(new Animated.Value(0)).current; const scrollX = useRef(new Animated.Value(0)).current;
function onScroll(event){ function onScroll(event){
if (event.nativeEvent.contentOffset.x === 0) { let rounded = Math.round(event.nativeEvent.contentOffset.x);
if (rounded === 0) {
props.modeSetter('square'); props.modeSetter('square');
} else if (event.nativeEvent.contentOffset.x === (Metrics.icons.buttonIcon * 2)) { } else if (rounded === (Metrics.icons.buttonIcon * 2)) {
props.modeSetter('addition'); props.modeSetter('addition');
} }
Animated.event([ Animated.event([

Loading…
Cancel
Save