Michaelvilleneuve / react-native-document-scanner

Document scanner, features live border detection, perspective correction, image filters and more ! 📲📸
MIT License
843 stars 289 forks source link

Add property to wait a timer before capture again #45

Closed WeslleyNasRocha closed 5 years ago

WeslleyNasRocha commented 5 years ago

With the following code, i got that result

export default class App extends Component {
  constructor(props) {
    super(props);

    this.state = { counter: 0 };
  }

  startCounter() {
    clearInterval(this.counter);
    this.setState({ counter: 0 }, () => {
      this.counter = setInterval(() => {
        this.setState(prevState => ({ counter: prevState.counter + 1 }));
      }, 1000);
    });
  }

  render() {
    return (
      <View style={styles.container}>
        <View style={{ marginTop: 16 }}>
          <Text>{this.state.counter}</Text>
        </View>
        <Scanner
          ref={ref => (this.scanner = ref)}
          onPictureTaken={data => this.startCounter()}
          captureMultiple
          overlayColor='#1599'
          timeBeteweenCaptures={15}
          style={{ flex: 1, width, height }}
        />
        <TouchableOpacity onPress={() => this.scanner.capture()}>
          <Text>Take Picture</Text>
        </TouchableOpacity>
      </View>
    );
  }
}

Imgur Gif was to big to put it here

WeslleyNasRocha commented 5 years ago

on my project i need these changes, i will make another pull request only with the feature