ref(video): remove deprecated lifecycle methods from gesture handler
This commit is contained in:
parent
10163274d3
commit
7614ceda68
|
@ -152,7 +152,8 @@ class VideoTransform extends Component<Props, State> {
|
|||
|
||||
this.state = {
|
||||
layout: null,
|
||||
transform: DEFAULT_TRANSFORM
|
||||
transform:
|
||||
this._getSavedTransform(props.streamId) || DEFAULT_TRANSFORM
|
||||
};
|
||||
|
||||
this._didMove = this._didMove.bind(this);
|
||||
|
@ -166,14 +167,7 @@ class VideoTransform extends Component<Props, State> {
|
|||
this._onPanResponderRelease = this._onPanResponderRelease.bind(this);
|
||||
this._onStartShouldSetPanResponder
|
||||
= this._onStartShouldSetPanResponder.bind(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements React Component's componentWillMount.
|
||||
*
|
||||
* @inheritdoc
|
||||
*/
|
||||
componentWillMount() {
|
||||
// The move threshold should be adaptive to the pixel ratio of the
|
||||
// screen to avoid making it too sensitive or difficult to handle on
|
||||
// different pixel ratio screens.
|
||||
|
@ -189,21 +183,17 @@ class VideoTransform extends Component<Props, State> {
|
|||
onShouldBlockNativeResponder: () => false,
|
||||
onStartShouldSetPanResponder: this._onStartShouldSetPanResponder
|
||||
});
|
||||
|
||||
const { streamId } = this.props;
|
||||
|
||||
this._restoreTransform(streamId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements React Component's componentWillReceiveProps.
|
||||
* Implements React Component's componentDidUpdate.
|
||||
*
|
||||
* @inheritdoc
|
||||
*/
|
||||
componentWillReceiveProps({ streamId: newStreamId }) {
|
||||
if (this.props.streamId !== newStreamId) {
|
||||
this._storeTransform();
|
||||
this._restoreTransform(newStreamId);
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
if (prevProps.streamId !== this.props.streamId) {
|
||||
this._storeTransform(prevProps.streamId, prevState.transform);
|
||||
this._restoreTransform(this.props.streamId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,7 +203,7 @@ class VideoTransform extends Component<Props, State> {
|
|||
* @inheritdoc
|
||||
*/
|
||||
componentWillUnmount() {
|
||||
this._storeTransform();
|
||||
this._storeTransform(this.props.streamId, this.state.transform);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -293,6 +283,20 @@ class VideoTransform extends Component<Props, State> {
|
|||
|| Math.abs(dy) > this.moveThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stored transform a stream should display with initially.
|
||||
*
|
||||
* @param {string} streamId - The id of the stream to match with a stored
|
||||
* transform.
|
||||
* @private
|
||||
* @returns {Object | null}
|
||||
*/
|
||||
_getSavedTransform(streamId) {
|
||||
const { enabled, _transforms } = this.props;
|
||||
|
||||
return (enabled && _transforms[streamId]) || null;
|
||||
}
|
||||
|
||||
_getTouchDistance: Object => number;
|
||||
|
||||
/**
|
||||
|
@ -647,31 +651,29 @@ class VideoTransform extends Component<Props, State> {
|
|||
* @returns {void}
|
||||
*/
|
||||
_restoreTransform(streamId) {
|
||||
const { enabled, _transforms } = this.props;
|
||||
const savedTransform = this._getSavedTransform(streamId);
|
||||
|
||||
if (enabled) {
|
||||
const initialTransform = _transforms[streamId];
|
||||
|
||||
if (initialTransform) {
|
||||
if (savedTransform) {
|
||||
this.setState({
|
||||
transform: initialTransform
|
||||
transform: savedTransform
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores/saves the current transform when the component is destroyed, or a
|
||||
* Stores/saves the a transform when the component is destroyed, or a
|
||||
* new stream is about to be rendered.
|
||||
*
|
||||
* @param {string} streamId - The stream id associated with the transform.
|
||||
* @param {Object} transform - The {@Transform} to save.
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
_storeTransform() {
|
||||
const { _onUnmount, enabled, streamId } = this.props;
|
||||
_storeTransform(streamId, transform) {
|
||||
const { _onUnmount, enabled } = this.props;
|
||||
|
||||
if (enabled) {
|
||||
_onUnmount(streamId, this.state.transform);
|
||||
_onUnmount(streamId, transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue