Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_pressButton = (callback) => {
const { marginTop } = this.state
let value = marginTop._value
if (Math.abs(value) >= 50) {
Animated.spring(marginTop, { toValue: 0, ...config }).start()
return true
}
this.content.clear()
Keyboard.dismiss()
// Animated.spring(openVal, { toValue: 0, ...config }).start(() => {
typeof callback === 'function' && callback()
this.props.navigation.goBack()
// });
}
BUTTON_POS.forEach((pos, i) => {
// Animate action buttons, iOS handles delay better
if (IOS) {
Animated.parallel([
Animated.delay(nextState === OPEN ?
BUTTON_POS.length * BUTTON_DELAY - (i * BUTTON_DELAY) :
0),
Animated.spring(this.state.buttons[i],
{ toValue: nextState === OPEN ?
pos :
{ x: 0, y: 0 } })
]).start();
} else {
Animated.spring(this.state.buttons[i],
{ toValue: nextState === OPEN ?
pos :
{ x: 0, y: 0 } }).start();
}
// Animate action button labels, 200ms later than buttons
Animated.parallel([
Animated.delay(nextState === OPEN ?
200 + BUTTON_POS.length * BUTTON_DELAY - (i * BUTTON_DELAY) :
0),
Animated.timing(this.state.labels[i],
{duration:200, toValue: nextState === OPEN ? 1 : 0})
]).start();
});
Animated.spring(this.state.plusButton, { toValue: nextState === OPEN ? 1 : 0 }).start();
handleTouch(data) {
// stop any animation this node was doing.
this.state.scale.stopAnimation();
this.state.opacity.stopAnimation();
this.scaledUp = true;
let tapAnimations = [];
tapAnimations.push(Animated.spring(this.state.scale, { toValue: 1.25, friction: 4, tension: 70 }));
tapAnimations.push(Animated.timing(this.state.opacity, {toValue: 0.2, duration: 100}));
Animated.parallel(tapAnimations).start();
this.touching = true;
this.touchTimeout = setTimeout(() => { this._onHoldAnimation(); }, 250);
}
spinArrow() {
if (!this.state.active) {
Animated.spring(this.containerAnim, {
toValue: 1
}).start();
Animated.spring(this.topBar, {
toValue: 1
}).start();
Animated.spring(this.bottomBar, {
toValue: 1
}).start();
Animated.spring(this.width, {
toValue: 14
}).start();
Animated.spring(this.marginLeft, {
toValue: -13
}).start();
Animated.spring(this.bottomBarMargin, {
toValue: 2
Animated.spring(this.angle, {
toValue: randomNumber(0, 2 * Math.PI)
}),
Animated.spring(this.startAngle, {
toValue: randomNumber(0, Math.PI)
}),
Animated.spring(this.endAngle, {
toValue: randomNumber(2 * Math.PI, 3 * Math.PI)
}),
Animated.spring(this.padAngle, { toValue: Math.random() }),
Animated.spring(this.radius, { toValue: randomNumber(50, 100) }),
Animated.spring(this.innerRadius, {
toValue: randomNumber(50, 100)
}),
Animated.spring(this.outerRadius, {
toValue: randomNumber(110, 150)
}),
Animated.spring(this.cornerRadius, { toValue: randomNumber(0, 5) }),
Animated.spring(this.padRadius, { toValue: randomNumber(0, 5) }),
Animated.spring(this.padding, { toValue: randomNumber(0, 5) }),
Animated.spring(this.nodeWidth, { toValue: randomNumber(5, 15) }),
Animated.spring(this.nodePadding, { toValue: randomNumber(5, 10) }),
Animated.spring(this.bandwidth, { toValue: randomNumber(40, 80) })
]).start(() => this.animate());
};
} else {
Animated.spring(this.state.rotation, {
toValue: this.rotationValue > 0.5 ? 1 : 0,
}).start(endState => {
if (endState.finished) {
this.state.rotation.setValue(0);
}
});
}
}
const progress = this.props.indeterminate
? indeterminateProgress || 0
: Math.min(Math.max(this.props.progress, 0), 1);
if (progress !== this.progressValue) {
if (this.props.animated) {
Animated.spring(this.state.progress, {
toValue: progress,
bounciness: 0,
}).start();
} else {
this.state.progress.setValue(progress);
}
}
}
duration: 30
}).start()
this.setState({
active: true
})
} else {
Animated.spring(this.containerAnim, {
toValue: 0
}).start()
Animated.spring(this.topBar, {
toValue: 0
}).start()
Animated.spring(this.bottomBar, {
toValue: 0
}).start()
Animated.spring(this.bottomBarMargin, {
toValue: 4
}).start()
Animated.timing(this.middleBarOpacity, {
toValue: 1,
duration: 600
}).start()
this.setState({
active: false
})
}
}
get disappearAnimates() {
let animates = super.disappearAnimates;
animates.push(
Animated.spring(this.state.marginValue, {
toValue: this.marginSize,
friction: 9,
})
);
return animates;
}
private subItemsExpandAnimate = (toValue: number): void => {
Animated.spring(this.subItemsAnimation, {
toValue: toValue,
}).start();
};