-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathARAnimatedProvider.js
More file actions
32 lines (32 loc) · 919 Bytes
/
ARAnimatedProvider.js
File metadata and controls
32 lines (32 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React, { createContext, Component } from "react";
import PropTypes from "prop-types";
import { setAnimation } from "./RNSwiftBridge";
const { Provider, Consumer } = createContext({});
class ARAnimatedProvider extends Component {
providerValue = {
willNativeUpdate: this.willNativeUpdate.bind(this),
didNativeUpdate: this.didNativeUpdate.bind(this)
};
render() {
return <Provider {...this.props} value={this.providerValue} />;
}
async willNativeUpdate() {
await setAnimation(
parseFloat(this.props.milliseconds) / 1000.0,
this.props.easing
);
}
async didNativeUpdate() {
//Do nothing
}
}
ARAnimatedProvider.defaultProps = {
milliseconds: 250,
easing: "inout"
};
ARAnimatedProvider.propTypes = {
milliseconds: PropTypes.number,
easing: PropTypes.string
};
export { ARAnimatedProvider, Consumer as ARAnimatedConsumer };
export default ARAnimatedProvider;