<commit_before>import ui.View as View;
import ui.ScrollView as ScrollView;

import .AdventureMapBackgroundView;
import .AdventureMapPathsView;
import .AdventureMapNodesView;
import .AdventureMapDoodadsView;
import math.geom.Point as Point;

exports = Class(ScrollView, function (supr) {
	var calls = 0;
	var calls_lf = 0;

	var h_padding = 10;
	var v_padding = 10;

	var h_slider_head = 20;
	var h_slider_tail = 0;
	var v_slider_head = 20;
	var v_slider_tail = 0;

	var v_head = 20 + v_padding*2;
	var v_tail = 0;
	var h_head = 20 + h_padding*2;
	var h_tail = 0;

	this.init = function (opts, model) {
		var width, height;

		this._model = model;
		this._tileWidth = opts.tileSettings.tileWidth;
		this._tileHeight = opts.tileSettings.tileHeight;

		this._gridSettings = opts.gridSettings;

		width = opts.gridSettings.width;
		height = opts.gridSettings.height;
		this._totalWidth = width * this._tileWidth;
		this._totalHeight = height * this._tileHeight;

		if (h_slider_head > width) {
			h_slider_head = width;
			h_head = width;
			h_padding = 0;
		}
		if (v_slider_head > height) {
			v_slider_head = height;
			v_head = height;
			v_padding = 0;
		}

		if (h_head > width) {
			h_head = width;
			h_padding = width - h_slider_head;
		}
		if (v_head > height) {
			v_head =  height;
			v_padding = height - v_slider_head;
		}

		this._touch = {};
		this._touchIDs = [];

		//playerview, to track a player
		this._playerView = null;

		var scale = opts.scale || 1;

		opts = merge(
			opts,
			{
				scrollX: true,
				scrollY: true,
				scrollBounds: {
					minX: 0,
					minY: 0,
					maxX: this._totalWidth * scale,
					maxY: this._totalHeight * scale
				},
				bounce: false,
				minScale: 0.5,
				maxScale: 2
			}
		);

		supr(this, 'init', [opts]);

		this._minScale = opts.minScale;
		this._maxScale = opts.maxScale;
		this._tileSettings = opts.tileSettings;
		this._adventureMapLayers = [];
		this._inputLayerIndex = opts.inputLayerIndex;

		this._showTimeout = null;

		this._fingerOne = null;
		this._fingerTwo = null;

		this._content = new View({
			superview: this,
			x: 0,
			y: 0,
			width: this._totalWidth,
			height: this._totalHeight,
			scale: scale
		});

		this._pinch = false;
		this._pinchScale = 1;
		this._pinchPoints = {};
		this._pinchStartDistance = 0;

		var ctors = [
				AdventureMapBackgroundView,
				AdventureMapPathsView,
				AdventureMapNodesView
			];
		for (var i = 0; i < ctors.length; i++) {
			this._adventureMapLayers.push(new ctors[i]({
				superview: this._content,
				adventureMapView: this,
				x: 0,
				y: 0,
				width: this._totalWidth,
				height: this._totalHeight,
				map: opts.map,
				tileCtor: ctors[i],
				tileSettings: opts.tileSettings,
				gridSettings: opts.gridSettings,
				nodeSettings: opts.nodeSettings,
				pathSettings: opts.pathSettings,
				editMode: opts.editMode,
				blockEvents: opts.editMode ? (i !== 0) : (i < 2),
				poolSize: v_head * h_head
			}));
		}

		this.on('Scrolled', bind(this, function (point) {
			var x = point.x || 0,
				y = point.y || 0;

			var adventureMapLayer = this._adventureMapLayers[0];
			this.move(x, y);
		}));
	};

	this.onUpdate = function (data) {
		data.pos = this.getPosition();
		for (var i = 0; i < 4; i++) {
			var adventureMapLayer = this._adventureMapLayers[i];
			if (adventureMapLayer && adventureMapLayer.onUpdate) {
				adventureMapLayer.onUpdate(data);
			}
		}

		this._showTimeout = this._showTimeout || setTimeout(
			bind(this, function () {
				for (var i = 0; i < 3; i++) {
					this._adventureMapLayers[i].style.visible = true;
				}
			}),
			0
		);
	};

	this.onPinch = function (pinchScale) {
		this.setScale(pinchScale);
	};

	this.onInputStart = function (evt, pt) {
		if (!this._touchIDs.length) {
			if (this._opts.drag) {
				this.startDrag({radius: this._opts.dragRadius * this._snapPixels});

				if (this._anim && this._anim.hasFrames()) {
					this._anim.clear();
				}

				evt.cancel();
			}
		}

		// Take only the first tap/finger
		// TODO: additional condition to allow pinch
		if (this._touchIDs.length === 0) {
			this._touch['_' + evt.id] = true;
			this._touchIDs = Object.keys(this._touch);
		} else {
			return;
		}

		switch (this._touchIDs.length) {
			case 1:
				this._fingerOne = this._touchIDs[0];
				this._pinchPoints[this._fingerOne] = {x: evt.srcPoint.x, y: evt.srcPoint.y};
				break;
			case 2:
				this._fingerTwo = this._touchIDs[1];<commit_msg>re-enable events on scroll stop<commit_after>import ui.View as View;
import ui.ScrollView as ScrollView;

import .AdventureMapBackgroundView;
import .AdventureMapPathsView;
import .AdventureMapNodesView;
import .AdventureMapDoodadsView;
import math.geom.Point as Point;

exports = Class(ScrollView, function (supr) {
	var calls = 0;
	var calls_lf = 0;

	var h_padding = 10;
	var v_padding = 10;

	var h_slider_head = 20;
	var h_slider_tail = 0;
	var v_slider_head = 20;
	var v_slider_tail = 0;

	var v_head = 20 + v_padding*2;
	var v_tail = 0;
	var h_head = 20 + h_padding*2;
	var h_tail = 0;

	this.init = function (opts, model) {
		var width, height;

		this._model = model;
		this._tileWidth = opts.tileSettings.tileWidth;
		this._tileHeight = opts.tileSettings.tileHeight;

		this._gridSettings = opts.gridSettings;

		width = opts.gridSettings.width;
		height = opts.gridSettings.height;
		this._totalWidth = width * this._tileWidth;
		this._totalHeight = height * this._tileHeight;

		if (h_slider_head > width) {
			h_slider_head = width;
			h_head = width;
			h_padding = 0;
		}
		if (v_slider_head > height) {
			v_slider_head = height;
			v_head = height;
			v_padding = 0;
		}

		if (h_head > width) {
			h_head = width;
			h_padding = width - h_slider_head;
		}
		if (v_head > height) {
			v_head =  height;
			v_padding = height - v_slider_head;
		}

		this._touch = {};
		this._touchIDs = [];

		//playerview, to track a player
		this._playerView = null;

		var scale = opts.scale || 1;

		opts = merge(
			opts,
			{
				scrollX: true,
				scrollY: true,
				scrollBounds: {
					minX: 0,
					minY: 0,
					maxX: this._totalWidth * scale,
					maxY: this._totalHeight * scale
				},
				bounce: false,
				minScale: 0.5,
				maxScale: 2
			}
		);

		supr(this, 'init', [opts]);

		this._minScale = opts.minScale;
		this._maxScale = opts.maxScale;
		this._tileSettings = opts.tileSettings;
		this._adventureMapLayers = [];
		this._inputLayerIndex = opts.inputLayerIndex;

		this._showTimeout = null;

		this._fingerOne = null;
		this._fingerTwo = null;

		this._content = new View({
			superview: this,
			x: 0,
			y: 0,
			width: this._totalWidth,
			height: this._totalHeight,
			scale: scale
		});

		this._pinch = false;
		this._pinchScale = 1;
		this._pinchPoints = {};
		this._pinchStartDistance = 0;

		var ctors = [
				AdventureMapBackgroundView,
				AdventureMapPathsView,
				AdventureMapNodesView
			];
		for (var i = 0; i < ctors.length; i++) {
			this._adventureMapLayers.push(new ctors[i]({
				superview: this._content,
				adventureMapView: this,
				x: 0,
				y: 0,
				width: this._totalWidth,
				height: this._totalHeight,
				map: opts.map,
				tileCtor: ctors[i],
				tileSettings: opts.tileSettings,
				gridSettings: opts.gridSettings,
				nodeSettings: opts.nodeSettings,
				pathSettings: opts.pathSettings,
				editMode: opts.editMode,
				blockEvents: opts.editMode ? (i !== 0) : (i < 2),
				poolSize: v_head * h_head
			}));
		}

		this.on('Scrolled', bind(this, function (point) {
			var x = point.x || 0,
				y = point.y || 0;

			var adventureMapLayer = this._adventureMapLayers[0];
			this.move(x, y);
		}));
	};

	this.onUpdate = function (data) {
		data.pos = this.getPosition();
		for (var i = 0; i < 4; i++) {
			var adventureMapLayer = this._adventureMapLayers[i];
			if (adventureMapLayer && adventureMapLayer.onUpdate) {
				adventureMapLayer.onUpdate(data);
			}
		}

		this._showTimeout = this._showTimeout || setTimeout(
			bind(this, function () {
				for (var i = 0; i < 3; i++) {
					this._adventureMapLayers[i].style.visible = true;
				}
			}),
			0
		);
	};

	this.onPinch = function (pinchScale) {
		this.setScale(pinchScale);
	};

	this.onInputStart = function (evt, pt) {
		if (!this._touchIDs.length) {
			if (this._opts.drag) {
				this.startDrag({radius: this._opts.dragRadius * this._snapPixels});

				if (this._anim && this._anim.hasFrames()) {
					this._contentView.getInput().blockEvents = false;
					this._anim.clear();
				}

				evt.cancel();
			}
		}

		// Take only the first tap/finger
		// TODO: additional condition to allow pinch
		if (this._touchIDs.length === 0) {
			this._touch['_' + evt.id] = true;
			this._touchIDs = Object.keys(this._touch);
		} else {
			return;
		}

		switch (this._touchIDs.length) {
			case 1:
				this._fingerOne = this._touchIDs[0];
				this._pinchPoints[this._fingerOne] = {x: evt.srcPoint.x, y: evt.srcPoint.y};
				break;
			case 2:
				this._fingerTwo = this._touchIDs[1];
{'fraction_non_alphanumeric': 0.1311806256306761, 'fraction_numerical': 0.011212019284673169, 'mean_word_length': 3.0490240581025874, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2464006', 'n_tokens_mistral': 3958, 'n_tokens_neox': 3243, 'n_words': 713}