<commit_before>
Ui.Container.extend('Ui.Carouselable', 
/**@lends Ui.Carouselable#*/
{
	movable: undefined,
	box: undefined,
	alignClock: undefined,
	speed: 0,
	animNext: 0,
	animStart: 0,
	ease: undefined,
	autoPlay: undefined,
	autoTask: undefined,
	pos: 0,
	startTime: undefined,

	/**
	 * @constructs
	 * @class
	 * @extends Ui.Container
	 */
	constructor: function(config) {
		this.addEvents('change', 'press');

		this.setClipToBounds(true);
		this.setFocusable(true);
		this.connect(this.getDrawing(), 'keydown', this.onKeyDown);
		this.connect(this.getDrawing(), 'keyup', this.onKeyUp);

		this.movable = new Ui.Movable({ inertia: false, moveVertical: false, directionRelease: true });
		this.movable.setFocusable(false);
		this.connect(this.movable, 'move', this.onMove);
		this.connect(this.movable, 'down', this.onDown);
		this.connect(this.movable, 'up', this.onUp);
		this.appendChild(this.movable);

		this.box = new Ui.CarouselableBox();
		this.movable.setContent(this.box);

		this.ease = Anim.EasingFunction.create({ type: Anim.PowerEase, mode: 'out' });
	},

	setAutoPlay: function(delay) {
		if(this.autoPlay != delay) {
			if(this.autoTask != undefined) {
				this.autoTask.abort();
				this.autoTask = undefined;
			}
			this.autoPlay = delay;
			if(this.autoPlay != undefined) {
				this.autoTask = new Core.DelayedTask({ delay: this.autoPlay, scope: this, callback: this.onAutoPlay });
			}
		}
	},

	getLock: function() {
		return this.movable.getLock();
	},

	setLock: function(lock) {
		this.movable.setLock(lock);
	},

	getCurrent: function() {
		return this.box.getChildren()[this.getCurrentPosition()];
	},

	getCurrentPosition: function() {
		return Math.min(this.box.getChildren().length - 1, Math.max(0, Math.round(-this.movable.getPositionX() / this.getLayoutWidth())));
	},

	setCurrentAt: function(position) {
		position = Math.min(this.box.getChildren().length - 1, Math.max(0, position));
		if(position < this.getCurrentPosition())
			this.startAnimation(1, position);
		else
			this.startAnimation(-1, position);
	},

	setCurrent: function(current) {
		for(var i = 0; i < this.box.getChildren().length; i++) {
			if(this.box.getChildren()[i] == current) {
				this.setCurrentAt(i);
				break;
			}
		}
	},

	next: function() {
		if(this.alignClock === undefined) {
			var currentPos = this.getCurrentPosition();
			if(currentPos < this.box.getChildren().length - 1)
				this.startAnimation(-1, currentPos + 1);
		}
		else {
			var pos = -this.movable.getPositionX() / this.getLayoutWidth();
			if(this.animNext > pos)
				this.startAnimation(-1 * (this.animNext+1-this.getCurrentPosition()), Math.min(this.animNext + 1, this.box.getChildren().length - 1));
			else
				this.startAnimation(-1, Math.min(Math.ceil(pos), this.box.getChildren().length - 1));
		}
	},

	previous: function() {
		if(this.alignClock === undefined) {
			var currentPos = this.getCurrentPosition();
			if(currentPos > 0)<commit_msg>change setCurrentAt to have constant time and not constante speed, looks better<commit_after>
Ui.Container.extend('Ui.Carouselable', 
/**@lends Ui.Carouselable#*/
{
	movable: undefined,
	box: undefined,
	alignClock: undefined,
	speed: 0,
	animNext: 0,
	animStart: 0,
	ease: undefined,
	autoPlay: undefined,
	autoTask: undefined,
	pos: 0,
	startTime: undefined,

	/**
	 * @constructs
	 * @class
	 * @extends Ui.Container
	 */
	constructor: function(config) {
		this.addEvents('change', 'press');

		this.setClipToBounds(true);
		this.setFocusable(true);
		this.connect(this.getDrawing(), 'keydown', this.onKeyDown);
		this.connect(this.getDrawing(), 'keyup', this.onKeyUp);

		this.movable = new Ui.Movable({ inertia: false, moveVertical: false, directionRelease: true });
		this.movable.setFocusable(false);
		this.connect(this.movable, 'move', this.onMove);
		this.connect(this.movable, 'down', this.onDown);
		this.connect(this.movable, 'up', this.onUp);
		this.appendChild(this.movable);

		this.box = new Ui.CarouselableBox();
		this.movable.setContent(this.box);

		this.ease = Anim.EasingFunction.create({ type: Anim.PowerEase, mode: 'out' });
	},

	setAutoPlay: function(delay) {
		if(this.autoPlay != delay) {
			if(this.autoTask != undefined) {
				this.autoTask.abort();
				this.autoTask = undefined;
			}
			this.autoPlay = delay;
			if(this.autoPlay != undefined) {
				this.autoTask = new Core.DelayedTask({ delay: this.autoPlay, scope: this, callback: this.onAutoPlay });
			}
		}
	},

	getLock: function() {
		return this.movable.getLock();
	},

	setLock: function(lock) {
		this.movable.setLock(lock);
	},

	getCurrent: function() {
		return this.box.getChildren()[this.getCurrentPosition()];
	},

	getCurrentPosition: function() {
		return Math.min(this.box.getChildren().length - 1, Math.max(0, Math.round(-this.movable.getPositionX() / this.getLayoutWidth())));
	},

	setCurrentAt: function(position) {
		position = Math.min(this.box.getChildren().length - 1, Math.max(0, position));
		this.startAnimation(this.getCurrentPosition()-position, position);
	},

	setCurrent: function(current) {
		for(var i = 0; i < this.box.getChildren().length; i++) {
			if(this.box.getChildren()[i] == current) {
				this.setCurrentAt(i);
				break;
			}
		}
	},

	next: function() {
		if(this.alignClock === undefined) {
			var currentPos = this.getCurrentPosition();
			if(currentPos < this.box.getChildren().length - 1)
				this.startAnimation(-1, currentPos + 1);
		}
		else {
			var pos = -this.movable.getPositionX() / this.getLayoutWidth();
			if(this.animNext > pos)
				this.startAnimation(-1 * (this.animNext+1-this.getCurrentPosition()), Math.min(this.animNext + 1, this.box.getChildren().length - 1));
			else
				this.startAnimation(-1, Math.min(Math.ceil(pos), this.box.getChildren().length - 1));
		}
	},

	previous: function() {
		if(this.alignClock === undefined) {
			var currentPos = this.getCurrentPosition();
			if(currentPos > 0)
{'fraction_non_alphanumeric': 0.1676839606646321, 'fraction_numerical': 0.00678195998643608, 'mean_word_length': 4.188214599824098, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, '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': '78711', 'n_tokens_mistral': 2252, 'n_tokens_neox': 2035, 'n_words': 363}