Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

扫描动画停止 #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/QRScanner.js
Expand Up @@ -53,6 +53,7 @@ export default class QRScanner extends PureComponent {
style={{
flex: 1
}}
captureAudio = {false}
onBarCodeRead={this._handleBarCodeRead}
barCodeTypes={[RNCamera.Constants.BarCodeType.qr]}
flashMode={!this.props.flashMode ? RNCamera.Constants.FlashMode.off : RNCamera.Constants.FlashMode.torch}
Expand Down
9 changes: 9 additions & 0 deletions src/QRScannerView.js
Expand Up @@ -52,6 +52,7 @@ export default class QRScannerView extends Component {
leftWidth: 0,
animatedValue: new Animated.Value(0)
}
this.isClosed = false;
}

//获取背景颜色
Expand Down Expand Up @@ -306,7 +307,15 @@ export default class QRScannerView extends Component {
this.scannerLineMove();
}

componentWillUnmount() {
this.isClosed = true;
}

scannerLineMove() {
if (this.isClosed) {
return;
}

this.state.animatedValue.setValue(0); //重置Rotate动画值为0
Animated.timing(
this.state.animatedValue,
Expand Down