<commit_before>'use strict';

var React   = require('react/addons');
var IScroll = require('iscroll');

/**
 * Scrollable is a wrapper element which makes the child element scrollable in
 * both X and Y dimensions.
 */
var Scrollable = React.createClass({

	propTypes: {
		/**
		 * The 'children' property must be a single child element, which will
		 * become the 'scroller' element.
		 */
		children: React.PropTypes.element.isRequired,

		/**
		 * The 'size' property determines the width and height of the element
		 * which Scrollable wraps.
		 */
		size: React.PropTypes.shape({
			width:  React.PropTypes.number,
			height: React.PropTypes.number,
		}).isRequired,
	},

	componentDidMount: function() {
		this.scroller = new IScroll(this.refs.wrapper.getDOMNode(), {
			scrollX:    true,
			scrollY:    true,
			freeScroll: true,
			indicators: {
				el:          this.refs.minimap.getDOMNode(),
				shrink:      false,
				resize:      false,
				interactive: true,
			},
		});

		this.resizeCursor();
	},

	componentWillUnmount: function() {
		this.scroller.destroy();
		this.scroller = null;
	},

	render: function() {
		var style =  {
			height:   '100%',
			overflow: 'hidden',
			position: 'relative',
		}
		return (
			<div className="scrollable">
				<div ref="wrapper" className="wrapper" style={style}>
					{this.props.children}
				</div>
				<div ref="minimap" className="minimap">
					<div ref="cursor" className="cursor" />
				</div>
			</div>
		);
	},

	/**
	 * Calculates the width and height for the 'cursor' element so that it
	 * matches the window size and orientation.
	 */
	resizeCursor: function() {<commit_msg>Add resize listener to scrollable<commit_after>'use strict';

var React   = require('react/addons');
var IScroll = require('iscroll');

/**
 * Scrollable is a wrapper element which makes the child element scrollable in
 * both X and Y dimensions.
 */
var Scrollable = React.createClass({

	propTypes: {
		/**
		 * The 'children' property must be a single child element, which will
		 * become the 'scroller' element.
		 */
		children: React.PropTypes.element.isRequired,

		/**
		 * The 'size' property determines the width and height of the element
		 * which Scrollable wraps.
		 */
		size: React.PropTypes.shape({
			width:  React.PropTypes.number,
			height: React.PropTypes.number,
		}).isRequired,
	},

	componentDidMount: function() {
		this.scroller = new IScroll(this.refs.wrapper.getDOMNode(), {
			scrollX:    true,
			scrollY:    true,
			freeScroll: true,
			indicators: {
				el:          this.refs.minimap.getDOMNode(),
				shrink:      false,
				resize:      false,
				interactive: true,
			},
		});

		// Force the refresh when the component is first mounted
		this._resizeMinimapCursor();

		// If we want to support IE8 and below, we have to use 'attachEvent'
		// instead of 'addEventListener' so let's not...
		window.addEventListener('resize', this._resizeMinimapCursor);
	},

	componentWillUnmount: function() {
		this.scroller.destroy();
		this.scroller = null;
	},

	render: function() {
		var style =  {
			height:   '100%',
			overflow: 'hidden',
			position: 'relative',
		}
		return (
			<div className="scrollable">
				<div ref="wrapper" className="wrapper" style={style}>
					{this.props.children}
				</div>
				<div ref="minimap" className="minimap">
					<div ref="cursor" className="cursor" />
				</div>
			</div>
		);
	},

	/**
	 * Resizes the width and height for the 'cursor' element so that it matches
	 * the window size and orientation.
	 */
	_resizeMinimapCursor: function() {
{'fraction_non_alphanumeric': 0.13260442949257079, 'fraction_numerical': 0.0019624334174376226, 'mean_word_length': 3.1296296296296298, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '394995', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1097, 'n_words': 314}