<commit_before>/**
 * @providesModule LightboxOverlay
 */
'use strict';

var React = require('react-native');
var {
  PropTypes,
  View,
  Text,
  Animated,
  StyleSheet,
  Dimensions,
  PanResponder,
  TouchableOpacity,
  StatusBarIOS,
  Modal,
  Platform,
} = React;

var WINDOW_HEIGHT = Dimensions.get('window').height;
var WINDOW_WIDTH = Dimensions.get('window').width;
var SPRING_CONFIG = { tension: 30, friction: 7 };
var DRAG_DISMISS_THRESHOLD = 150;
var STATUS_BAR_OFFSET = (Platform.OS === 'android' ? -25 : 0);

var LightboxOverlay = React.createClass({
  getInitialState: function() {
    return {
      isAnimating: false,
      isPanning: false,
      target: {
        x: 0,
        y: 0,
        opacity: 1,
      },
      pan: new Animated.Value(0),
      openVal: new Animated.Value(0),
      layoutOpacity: new Animated.Value(1),
    };
  },

  componentWillMount: function() {
    this._panResponder = PanResponder.create({
      // Ask to be the responder:
      onStartShouldSetPanResponder: (evt, gestureState) => !this.state.isAnimating,
      onStartShouldSetPanResponderCapture: (evt, gestureState) => !this.state.isAnimating,
      onMoveShouldSetPanResponder: (evt, gestureState) => !this.state.isAnimating,
      onMoveShouldSetPanResponderCapture: (evt, gestureState) => !this.state.isAnimating,

      onPanResponderGrant: (evt, gestureState) => {
        this.state.pan.setValue(0);
        this.setState({ isPanning: true });
      },
      onPanResponderMove: Animated.event([
        null,
        {dy: this.state.pan}
      ]),
      onPanResponderTerminationRequest: (evt, gestureState) => true,
      onPanResponderRelease: (evt, gestureState) => {
        if(Math.abs(gestureState.dy) > DRAG_DISMISS_THRESHOLD) {
          this.setState({
            isPanning: false,
            target: {
              y: gestureState.dy,
              x: gestureState.dx,
              opacity: 1 - Math.abs(gestureState.dy / WINDOW_HEIGHT)
            }
          });
          this.close();
        } else {
          Animated.spring(
            this.state.pan,
            {toValue: 0, ...SPRING_CONFIG}
          ).start(() => { this.setState({ isPanning: false }); });
        }
      },
    });
    if(this.props.isOpen) {
      this.open();
    }
  },

  open: function() {
    if(StatusBarIOS) {
      StatusBarIOS.setHidden(true, 'fade');
    }
    this.state.pan.setValue(0);
    this.setState({
      isAnimating: true,
      target: {
        x: 0,
        y: 0,
        opacity: 1,
      }
    });

    Animated.spring(
      this.state.openVal,
      { toValue: 1, ...SPRING_CONFIG }
    ).start(() => this.setState({ isAnimating: false }));
  },

  close: function() {
    if(StatusBarIOS) {
      StatusBarIOS.setHidden(false, 'fade');
    }
    this.setState({
      isAnimating: true,
    });
    Animated.spring(
      this.state.openVal,
      { toValue: 0, ...SPRING_CONFIG }
    ).start(() => {
      this.props.onClose();
      // Delay isOpen until next tick to avoid flicker.
      setTimeout(() => {
        this.setState({
          isAnimating: false,
        });
      });
    });
  },

  componentWillReceiveProps: function(props) {
    if(this.props.isOpen != props.isOpen) {
      if(props.isOpen) {
        this.open();
      }
    }<commit_msg>Fixed warning caused by setting state after component is unmounted.<commit_after>/**
 * @providesModule LightboxOverlay
 */
'use strict';

var React = require('react-native');
var {
  PropTypes,
  View,
  Text,
  Animated,
  StyleSheet,
  Dimensions,
  PanResponder,
  TouchableOpacity,
  StatusBarIOS,
  Modal,
  Platform,
} = React;

var WINDOW_HEIGHT = Dimensions.get('window').height;
var WINDOW_WIDTH = Dimensions.get('window').width;
var SPRING_CONFIG = { tension: 30, friction: 7 };
var DRAG_DISMISS_THRESHOLD = 150;
var STATUS_BAR_OFFSET = (Platform.OS === 'android' ? -25 : 0);

var LightboxOverlay = React.createClass({
  getInitialState: function() {
    return {
      isAnimating: false,
      isPanning: false,
      target: {
        x: 0,
        y: 0,
        opacity: 1,
      },
      pan: new Animated.Value(0),
      openVal: new Animated.Value(0),
      layoutOpacity: new Animated.Value(1),
    };
  },

  componentWillMount: function() {
    this._panResponder = PanResponder.create({
      // Ask to be the responder:
      onStartShouldSetPanResponder: (evt, gestureState) => !this.state.isAnimating,
      onStartShouldSetPanResponderCapture: (evt, gestureState) => !this.state.isAnimating,
      onMoveShouldSetPanResponder: (evt, gestureState) => !this.state.isAnimating,
      onMoveShouldSetPanResponderCapture: (evt, gestureState) => !this.state.isAnimating,

      onPanResponderGrant: (evt, gestureState) => {
        this.state.pan.setValue(0);
        this.setState({ isPanning: true });
      },
      onPanResponderMove: Animated.event([
        null,
        {dy: this.state.pan}
      ]),
      onPanResponderTerminationRequest: (evt, gestureState) => true,
      onPanResponderRelease: (evt, gestureState) => {
        if(Math.abs(gestureState.dy) > DRAG_DISMISS_THRESHOLD) {
          this.setState({
            isPanning: false,
            target: {
              y: gestureState.dy,
              x: gestureState.dx,
              opacity: 1 - Math.abs(gestureState.dy / WINDOW_HEIGHT)
            }
          });
          this.close();
        } else {
          Animated.spring(
            this.state.pan,
            {toValue: 0, ...SPRING_CONFIG}
          ).start(() => { this.setState({ isPanning: false }); });
        }
      },
    });
    if(this.props.isOpen) {
      this.open();
    }
  },

  open: function() {
    if(StatusBarIOS) {
      StatusBarIOS.setHidden(true, 'fade');
    }
    this.state.pan.setValue(0);
    this.setState({
      isAnimating: true,
      target: {
        x: 0,
        y: 0,
        opacity: 1,
      }
    });

    Animated.spring(
      this.state.openVal,
      { toValue: 1, ...SPRING_CONFIG }
    ).start(() => this.setState({ isAnimating: false }));
  },

  close: function() {
    if(StatusBarIOS) {
      StatusBarIOS.setHidden(false, 'fade');
    }
    this.setState({
      isAnimating: true,
    });
    Animated.spring(
      this.state.openVal,
      { toValue: 0, ...SPRING_CONFIG }
    ).start(() => {
      this.props.onClose();
      this.setState({
        isAnimating: false,
      });
    });
  },

  componentWillReceiveProps: function(props) {
    if(this.props.isOpen != props.isOpen) {
      if(props.isOpen) {
        this.open();
      }
    }
{'fraction_non_alphanumeric': 0.13968012185833967, 'fraction_numerical': 0.007311500380807311, 'mean_word_length': 2.2780828756864704, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2711507', 'n_tokens_mistral': 2222, 'n_tokens_neox': 2168, 'n_words': 394}