<commit_before>(function(window) {
	"use strict";

	var dom     = window.dom;
	var on      = dom.events.on;
	var trigger = dom.events.trigger;
	var closest = dom.closest;
	var tau     = Math.PI * 2;

	var elasticDistance = 800;

	function elasticEase(n) {
		return Math.atan(n) / Math.PI ;
	}

	on(document, 'touch', function(e) {
		if (e.defaultPrevented) { return; }

		var node = closest('.slideable', e.target);
		if (!node) { return; }

		var classes = dom.classes(node);
		var transform = dom.style('transform', node);

		transform = !transform || transform === 'none' ? '' : transform ;

		var x = dom.style('transform:translateX', node);
		var last = dom(node.children)
			.filter(dom.matches('.switchable'))
			.last()
			.shift();

		// Get the right-most x of the last switchable child's right-most edge
		var w1 = last.offsetLeft + last.clientWidth;
		var w2 = node.parentNode.clientWidth;
		var ws = w1 - w2;

		classes.add('notransition');

		// e.detail() is a stream of touch coordinates
		e.detail()
		.map(function(data) {
			var ax = x + data.x;
			var tx = ax > 0 ? elasticEase(ax / elasticDistance) * elasticDistance - x :
				ax < -ws ? elasticEase((ax + ws) / elasticDistance) * elasticDistance - ws - x :
				data.x ;

			return transform + ' translate(' + tx + 'px, 0px)';
		})
		.each(function(transform) {
			node.style.transform = transform;
		})
		.on('done', function() {
			classes.remove('notransition');
		});
	});

	on(document, 'swipe', function(e) {
		if (e.defaultPrevented) { return; }

		var node = closest('.slideable', e.target);
		if (!node) { return; }

		var angle    = Fn.wrap(0, tau, e.angle || 0);
		var velocity = e.velocity || 0;

			// If angle is rightwards
		var prop = (angle > tau * 1/8 && angle < tau * 3/8) ?
				'previousElementSibling' :
			// If angle is leftwards
			(angle > tau * 5/8 && angle < tau * 7/8) ?
				'nextElementSibling' :<commit_msg>Adds support for data-slide-min data-slide-max data-slide-snap to slideables<commit_after>(function(window) {
	"use strict";

	var dom     = window.dom;
	var on      = dom.events.on;
	var trigger = dom.events.trigger;
	var closest = dom.closest;
	var tau     = Math.PI * 2;

	var elasticDistance = 800;

	var rspaces = /\s+/;

	function elasticEase(n) {
		return Math.atan(n) / Math.PI ;
	}

	function xMinFromChildren(node) {
		var last = dom(node.children)
			.filter(dom.matches('.switchable'))
			.last()
			.shift();
		
		// Get the right-most x of the last switchable child's right-most edge
		var w1 = last.offsetLeft + last.clientWidth;
		var w2 = node.parentNode.clientWidth;
		return w2 - w1;
	}

	on(document, 'touch', function(e) {
		if (e.defaultPrevented) { return; }

		var node = closest('.slideable', e.target);
		if (!node) { return; }

		var classes = dom.classes(node);
		var transform = dom.style('transform', node);

		transform = !transform || transform === 'none' ? '' : transform ;

		var x = dom.style('transform:translateX', node);
console.log(x);
		// Elastic flags and limits
		var eMin = false;
		var eMax = false;
		var xMin = dom.attribute('data-slide-min', node);
		var xMax = dom.attribute('data-slide-max', node);

		if (!xMin && !xMax) {
			eMin = true;
			eMax = true;
			xMin = xMinFromChildren(node);
			xMax = 0;
		}
		else {
			eMin = /elastic/.test(xMin);
			eMax = /elastic/.test(xMax);
			xMin = parseFloat(xMin) || 0;
			xMax = parseFloat(xMax) || 0;
		}

		classes.add('notransition');

		var ax = x;

		// e.detail() is a stream of touch coordinates
		e.detail()
		.map(function(data) {
			ax = x + data.x;
			var tx = ax > 0 ?
					eMax ? elasticEase(ax / elasticDistance) * elasticDistance - x :
					xMax :
				ax < xMin ?
					eMin ? elasticEase((ax - xMin) / elasticDistance) * elasticDistance + xMin - x :
					xMin :
				data.x ;

			return transform + ' translate(' + tx + 'px, 0px)';
		})
		.each(function(transform) {
			node.style.transform = transform;
		})
		.on('done', function() {
			classes.remove('notransition');

			// Todo: Watch out, this may interfere with slides
			var xSnaps = dom.attribute('data-slide-snap', node);
console.log(xSnaps)
			if (!xSnaps) { return; }
			xSnaps = xSnaps.split(rspaces).map(parseFloat);
console.log(xSnaps)
			// Get closest x from list of snaps
			var tx = xSnaps.reduce(function(prev, curr) {
				return Math.abs(curr - ax) < Math.abs(prev - ax) ?
					curr : prev ;
			});
console.log(tx);

			//requestAnimationFrame(function() {
				node.style.transform = transform + ' translate(' + tx + 'px, 0px)';
			//});
		});
	});

	on(document, 'swipe', function(e) {
		if (e.defaultPrevented) { return; }

		var node = closest('.slideable', e.target);
		if (!node) { return; }

		var angle    = Fn.wrap(0, tau, e.angle || 0);
		var velocity = e.velocity || 0;

			// If angle is rightwards
		var prop = (angle > tau * 1/8 && angle < tau * 3/8) ?
				'previousElementSibling' :
			// If angle is leftwards
			(angle > tau * 5/8 && angle < tau * 7/8) ?
				'nextElementSibling' :
{'fraction_non_alphanumeric': 0.161115569823435, 'fraction_numerical': 0.009229534510433388, 'mean_word_length': 2.9190251572327046, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, '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': '4696693', 'n_tokens_mistral': 2046, 'n_tokens_neox': 1743, 'n_words': 451}