<commit_before>Swapper._swapper = function (os, isNode, isInDOM, insertBefore, insertAfter, removeNode, setTransform, setTransition, getStyles, transitions, easings, validate, window, document) {
	var NO_TRANSFORM       = 'translate3d(0,0,0) scale(1)',
		DEFAULT_TRANSITION = 'fade',
		DEFAULT_EASING     = 'ease-in-out';

	var isIOS5 = (os.ios && (Math.floor(os.version) === 5));



	function swapper (elem1, elem2, options, callback) {
		validate.element(elem1);
		validate.element(elem2);

		if (typeof options === 'function') {
			callback = options;
			options  = {};
		}

		options  = validate.options(options);
		callback = validate.callback(callback);

		if (elem1._swapper) {
			throw Error('elem1 is currently being swapped');
		}
		else if (elem2._swapper) {
			throw Error('elem2 is currently being swapped');
		}

		if ( !isInDOM(elem1, true) ) {
			throw Error('elem1 must be in the DOM to be swapped');
		}

		elem1._swapper = true;
		elem2._swapper = true;

		removeNode(elem2);

		performSwap(elem1, elem2, options, function () {
			elem1._swapper = false;
			elem2._swapper = false;
			callback();
		});
	}



	function performSwap (elem1, elem2, options, callback) {
		if (options.transition === 'instant') {
			insertAfter(elem2, elem1);
			removeNode(elem1);
			callback();
			return;
		}


		var transition = transitions[options.transition || DEFAULT_TRANSITION],
			easing     = easings[options.easing || DEFAULT_EASING],
			duration   = options.duration || 300;

		// do this first to get accurate style readings
		insertAfter(elem2, elem1);

		var computedStyles1 = getStyles(elem1),
			computedStyles2 = getStyles(elem2),
			styles1         = getStyles(elem1, true),
			styles2         = getStyles(elem2, true);

		setInitialPosition(elem1, elem2, computedStyles1, computedStyles2);

		if ( transition[2] ) {
			insertBefore(elem2, elem1);
		}

		elem2.style.opacity = '0';
		setInitialTransitions(elem1, elem2);

		setTimeout(function () {
			elem2.style.display = computedStyles2.opacity;
			setInitialTransforms(elem1, elem2, transition);

			setTimeout(function () {
				setSwapperTransitions(elem1, elem2, duration, easing);

				setTimeout(function () {
					setFinalTransforms(elem1, elem2, transition);

					onTransitionEnd(elem1          , elem2          ,
									computedStyles1, computedStyles2,
									transition     , duration       ,
						function () {
							removeNode(elem1);

							removeSwapperTransitions(elem1, elem2, duration, easing);

							setTimeout(function () {
								restoreTransforms(elem1, elem2, styles1, styles2, transition);
								restorePosition(elem1, elem2, styles1, styles2);

								setTimeout(function () {
									restoreTransitions(elem1, elem2, styles1, styles2);

									callback();<commit_msg>bugfix for opacity transition<commit_after>Swapper._swapper = function (os, isNode, isInDOM, insertBefore, insertAfter, removeNode, setTransform, setTransition, getStyles, transitions, easings, validate, window, document) {
	var NO_TRANSFORM       = 'translate3d(0,0,0) scale(1)',
		DEFAULT_TRANSITION = 'fade',
		DEFAULT_EASING     = 'ease-in-out';

	var isIOS5 = (os.ios && (Math.floor(os.version) === 5));



	function swapper (elem1, elem2, options, callback) {
		validate.element(elem1);
		validate.element(elem2);

		if (typeof options === 'function') {
			callback = options;
			options  = {};
		}

		options  = validate.options(options);
		callback = validate.callback(callback);

		if (elem1._swapper) {
			throw Error('elem1 is currently being swapped');
		}
		else if (elem2._swapper) {
			throw Error('elem2 is currently being swapped');
		}

		if ( !isInDOM(elem1, true) ) {
			throw Error('elem1 must be in the DOM to be swapped');
		}

		elem1._swapper = true;
		elem2._swapper = true;

		removeNode(elem2);

		performSwap(elem1, elem2, options, function () {
			elem1._swapper = false;
			elem2._swapper = false;
			callback();
		});
	}



	function performSwap (elem1, elem2, options, callback) {
		if (options.transition === 'instant') {
			insertAfter(elem2, elem1);
			removeNode(elem1);
			callback();
			return;
		}


		var transition = transitions[options.transition || DEFAULT_TRANSITION],
			easing     = easings[options.easing || DEFAULT_EASING],
			duration   = options.duration || 300;

		// do this first to get accurate style readings
		insertAfter(elem2, elem1);

		var computedStyles1 = getStyles(elem1),
			computedStyles2 = getStyles(elem2),
			styles1         = getStyles(elem1, true),
			styles2         = getStyles(elem2, true);

		setInitialPosition(elem1, elem2, computedStyles1, computedStyles2);

		if ( transition[2] ) {
			insertBefore(elem2, elem1);
		}

		elem2.style.opacity = '0';
		setInitialTransitions(elem1, elem2);

		setTimeout(function () {
			elem2.style.opacity = computedStyles2.opacity;
			setInitialTransforms(elem1, elem2, transition);

			setTimeout(function () {
				setSwapperTransitions(elem1, elem2, duration, easing);

				setTimeout(function () {
					setFinalTransforms(elem1, elem2, transition);

					onTransitionEnd(elem1          , elem2          ,
									computedStyles1, computedStyles2,
									transition     , duration       ,
						function () {
							removeNode(elem1);

							removeSwapperTransitions(elem1, elem2, duration, easing);

							setTimeout(function () {
								restoreTransforms(elem1, elem2, styles1, styles2, transition);
								restorePosition(elem1, elem2, styles1, styles2);

								setTimeout(function () {
									restoreTransitions(elem1, elem2, styles1, styles2);

									callback();
{'fraction_non_alphanumeric': 0.12051649928263988, 'fraction_numerical': 0.028694404591104734, 'mean_word_length': 3.5267857142857144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1139635', 'n_tokens_mistral': 2127, 'n_tokens_neox': 1762, 'n_words': 386}