<commit_before>/* global define, window */
define(['jquery', 'tmclasses/tmclasses'], function(jQuery, tmclasses){
	var __ParallaxBackground = tmclasses.create({
		init: function(){
			this.__parent(arguments);
			if(this.elm){
				this.constructor.window.on('load resize scroll', jQuery.proxy(this._changeHandler, this));
			}
		}
		,properties: {
			elm: undefined
			,movementRatio: 0.8
			,_changeHandler: function(){
				var _viewportHeight = this.constructor.window.height();
				var _viewportTop = this.constructor.window.scrollTop();
				var _elmHeight = this.elm.outerHeight();
				var _elmTop = this.elm.offset().top;
				var _range = _elmHeight + _viewportHeight;
				var _calcOffset = _elmTop - _viewportHeight;
				var _diff = -((_viewportTop - _calcOffset) - _range);
				var _bgPosition;
				if(_diff > _range){
					_bgPosition = 100;
				}else if(_diff < 0){
					_bgPosition = 0;
				}else{
					_bgPosition = (_diff / _range) * 100;
				}
				_bgPosition = _bgPosition - 50;
				_bgPosition = 50 + _bgPosition * this.movementRatio;

				this.elm.css('background-position', 'center ' + _bgPosition + '%');
			}
		}
		,statics: {
			window: jQuery(window)
		}
	});
	return __ParallaxBackground;
});<commit_msg>ui/parallaxbackground: added 'centeredStart' calculation type, now default<commit_after>/* global define, window */
define(['jquery', 'tmclasses/tmclasses'], function(jQuery, tmclasses){
	var __ParallaxBackground = tmclasses.create({
		init: function(){
			this.__parent(arguments);
			if(this.elm){
				this.constructor.window.on('load resize scroll', jQuery.proxy(this._changeHandler, this));
			}
		}
		,properties: {
			elm: undefined
			,calcType: 'centeredStart'
			,movementRatio: 0.8
			,_changeHandler: function(){
				var _viewportHeight = this.constructor.window.height();
				var _viewportTop = this.constructor.window.scrollTop();
				var _elmHeight = this.elm.outerHeight();
				var _elmTop = this.elm.offset().top;
				var _range = _elmHeight + _viewportHeight;
				var _calcOffset = _elmTop - _viewportHeight;
				var _diff = -((_viewportTop - _calcOffset) - _range);
				var _bgPosition;
				if(_diff > _range){
					_bgPosition = 100;
				}else if(_diff < 0){
					_bgPosition = 0;
				}else{
					_bgPosition = (_diff / _range) * 100;
				}
				switch(this.calcType){
					case 'centered':
						_bgPosition = 50 + (_bgPosition - 50) * this.movementRatio;
					break;
					case 'centeredStart':
						if(typeof this._startOffset === 'undefined'){
							var _startingPosition = this.elm.css('background-position-y');
							if(_startingPosition.indexOf('%') !== -1){
								_startingPosition = parseInt(_startingPosition,10);
							}
							this._startOffset = -1 * (50 + (_bgPosition - 50) * this.movementRatio - _startingPosition);
						}
						_bgPosition = 50 + (_bgPosition - 50) * this.movementRatio + this._startOffset;
					break;
				}

				this.elm.css('background-position', 'center ' + _bgPosition + '%');
			}
			,_startOffset: undefined
		}
		,statics: {
			window: jQuery(window)
		}
	});
	return __ParallaxBackground;
});
{'fraction_non_alphanumeric': 0.13905996758508915, 'fraction_numerical': 0.012965964343598054, 'mean_word_length': 3.377304964539007, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7530604', 'n_tokens_mistral': 1259, 'n_tokens_neox': 981, 'n_words': 204}