<commit_before>/*
---

name: Scroller.Engine.Native

description: Provides a native scroller engine.

license: MIT-style license.

authors:
	- <NAME> (<EMAIL>)

requires:
	- Scroller.Engine

provides:
	- Scroller.Engine.Native

...
*/

/**
 * @name  Scroller.Engine.Native
 * @class Provides an engine that uses the native scroller overflow.
 *
 * @classdesc
 *
 * [TODO: Introduction]
 * [TODO: Events]
 * [TODO: Options]
 *
 * @author  <NAME> (<EMAIL>)
 * @version 0.1
 */
Moobile.Scroller.Engine.Native = new Class( /** @lends Scroller.Engine.Native.prototype */ {

	Extends: Moobile.Scroller.Engine,

	scroller: null,

	scrolling: false,

	/**
	 * Initializes this scroller engine.
	 *
	 * This method will creates a `wrapper` element and wrap it around the
	 * given `content` element.
	 *
	 * @param {Element}	[content] The Element, element id or string.
	 * @param {Object}  [options] The options.
	 *
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	initialize: function(content, options) {

		this.parent(content, options);

		this.wrapper.addClass('scroll-engine-native');

		if (this.options.scrollX)  this.wrapper.setStyle('overflow-x', 'scroll');
		if (this.options.scrollY)  this.wrapper.setStyle('overflow-y', 'scroll');
		if (this.options.momentum) this.wrapper.setStyle('-webkit-overflow-scrolling', 'touch');

		this.scroller = new Fx.Scroll(this.wrapper);

		this.wrapper.addEvent('touchstart', this.bound('onTouchStart'));
		this.wrapper.addEvent('touchend', this.bound('onTouchEnd'));
		this.wrapper.addEvent('scroll', this.bound('onScroll'));

		window.addEvent('rotate', this.bound('onWindowRotate'));

		return this;
	},

	/**
	 * Destroys this scroller engine.
	 *
	 * This method will remove the wrapper without removing the content
	 * element.
	 *
	 * @return {Scroller.Engine} This scroller engine.
	 *
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	destroy: function() {
		window.removeEvent('rotate', this.bound('onWindowRotate'));
		this.scroller = null;
		this.parent();
	},

	/**
	 * Scrolls to a set of coordinates.
	 *
	 * @param {Number} x      The x coordinate.
	 * @param {Number} y      The y coordinate.
	 * @param {Number} [time] The duration of the scroll.
	 *
	 * @return {Scroller.Engine} This scroller engine.
	 *
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	scrollTo: function(x, y, time) {

		time = time || 0;

		this.scroller.setOptions({duration: time});
		this.scroller.start(x, y);
		// TODO: proper events
		return this;
	},

	/**
	 * Scrolls to an element.
	 *
	 * @param {Element} element The element to scroll to.
	 * @param {Number}  [time]  The duration of the scroll.
	 *
	 * @return {Scroller.Engine} This scroller engine.
	 *
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	scrollToElement: function(element, time) {

		time = time || 0;

		element = document.id(element);

		this.scroller.setOptions({duration: time});
		this.scroller.toElement(element);

		return this;
	},

	/**
	 * Refreshes this scroller engine.
	 *
	 * @return {Scroller} This scroller.
	 *
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	refresh: function() {

		var wrapperSize = this.getSize();
		var contentSize = this.getScrollSize();

		if (contentSize.y <= wrapperSize.y) {
			this.content.setStyle('min-height', wrapperSize.y + 1);
		}

		return this;
	},

	/**
	 * Returns the size.
	 *
	 * This method will return the wrapper's size as an object with two keys,
	 * `x` which indicates the width and `y` which indicates the height.<commit_msg>Adding 2 pixels instead of one fixes cases where the entire browser moves when scrolling<commit_after>/*
---

name: Scroller.Engine.Native

description: Provides a native scroller engine.

license: MIT-style license.

authors:
	- <NAME> (<EMAIL>)

requires:
	- Scroller.Engine

provides:
	- Scroller.Engine.Native

...
*/

/**
 * @name  Scroller.Engine.Native
 * @class Provides an engine that uses the native scroller overflow.
 *
 * @classdesc
 *
 * [TODO: Introduction]
 * [TODO: Events]
 * [TODO: Options]
 *
 * @author  <NAME> (<EMAIL>)
 * @version 0.1
 */
Moobile.Scroller.Engine.Native = new Class( /** @lends Scroller.Engine.Native.prototype */ {

	Extends: Moobile.Scroller.Engine,

	scroller: null,

	scrolling: false,

	/**
	 * Initializes this scroller engine.
	 *
	 * This method will creates a `wrapper` element and wrap it around the
	 * given `content` element.
	 *
	 * @param {Element}	[content] The Element, element id or string.
	 * @param {Object}  [options] The options.
	 *
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	initialize: function(content, options) {

		this.parent(content, options);

		this.wrapper.addClass('scroll-engine-native');

		if (this.options.scrollX)  this.wrapper.setStyle('overflow-x', 'scroll');
		if (this.options.scrollY)  this.wrapper.setStyle('overflow-y', 'scroll');
		if (this.options.momentum) this.wrapper.setStyle('-webkit-overflow-scrolling', 'touch');

		this.scroller = new Fx.Scroll(this.wrapper);

		this.wrapper.addEvent('touchstart', this.bound('onTouchStart'));
		this.wrapper.addEvent('touchend', this.bound('onTouchEnd'));
		this.wrapper.addEvent('scroll', this.bound('onScroll'));

		window.addEvent('rotate', this.bound('onWindowRotate'));

		return this;
	},

	/**
	 * Destroys this scroller engine.
	 *
	 * This method will remove the wrapper without removing the content
	 * element.
	 *
	 * @return {Scroller.Engine} This scroller engine.
	 *
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	destroy: function() {
		window.removeEvent('rotate', this.bound('onWindowRotate'));
		this.scroller = null;
		this.parent();
	},

	/**
	 * Scrolls to a set of coordinates.
	 *
	 * @param {Number} x      The x coordinate.
	 * @param {Number} y      The y coordinate.
	 * @param {Number} [time] The duration of the scroll.
	 *
	 * @return {Scroller.Engine} This scroller engine.
	 *
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	scrollTo: function(x, y, time) {

		time = time || 0;

		this.scroller.setOptions({duration: time});
		this.scroller.start(x, y);
		// TODO: proper events
		return this;
	},

	/**
	 * Scrolls to an element.
	 *
	 * @param {Element} element The element to scroll to.
	 * @param {Number}  [time]  The duration of the scroll.
	 *
	 * @return {Scroller.Engine} This scroller engine.
	 *
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	scrollToElement: function(element, time) {

		time = time || 0;

		element = document.id(element);

		this.scroller.setOptions({duration: time});
		this.scroller.toElement(element);

		return this;
	},

	/**
	 * Refreshes this scroller engine.
	 *
	 * @return {Scroller} This scroller.
	 *
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	refresh: function() {

		var wrapperSize = this.getSize();
		var contentSize = this.getScrollSize();

		if (contentSize.y <= wrapperSize.y) {
			this.content.setStyle('min-height', wrapperSize.y + 2);
		}

		return this;
	},

	/**
	 * Returns the size.
	 *
	 * This method will return the wrapper's size as an object with two keys,
	 * `x` which indicates the width and `y` which indicates the height.
{'fraction_non_alphanumeric': 0.1532815808045166, 'fraction_numerical': 0.004375441072688779, 'mean_word_length': 3.3876160990712076, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 31, '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': '3819822', 'n_tokens_mistral': 2548, 'n_tokens_neox': 2293, 'n_words': 625}