<commit_before>import { stop, animate, Promise, isAnimating, finish } from "liquid-fire";
import jQuery from "jquery";

export default function moveOverHalf(dimension, direction, opts) {
  var oldParams = {};
  var newParams = {};
  var overlayParams = {};
  var firstStep;
  var property;
  var measure;

  var darkOpacity = 0.75;
  if (direction > 0) {
    // moving right
    overlayParams = {
      opacity: [0, darkOpacity]
    };
  } else {
    // moving left
    overlayParams = {
      opacity: [darkOpacity, 0]
    };
  }

  var overlay = jQuery('<div class="transition-overlay"></div>');
  this.oldElement.append(overlay);

  if (dimension.toLowerCase() === 'x') {
    property = 'translateX';
    measure = 'width';
  } else {
    property = 'translateY';
    measure = 'height';
  }

  if (isAnimating(this.oldElement, 'moving-in')) {
    firstStep = finish(this.oldElement, 'moving-in');
  } else {
    stop(this.oldElement);
    firstStep = Promise.resolve();
  }

  return firstStep.then(() => {
    var bigger = biggestSize(this, measure);

    this.oldElement[0].style.zIndex = direction > 0 ? 5 : 0;
    this.newElement[0].style.zIndex = direction > 0 ? 0 : 5;

    oldParams[property] = (bigger * (direction > 0 ? 1 : -0.5)) + 'px';
    newParams[property] = ["0px", (bigger * (direction > 0 ? -0.5 : 1)) + 'px'];

    return Promise.all([
      animate(overlay, overlayParams, opts),
      animate(this.oldElement, oldParams, opts),
      animate(this.newElement, newParams, opts, 'moving-in')
    ]);
  });
}

function biggestSize(context, dimension) {
  var sizes = [];
  if (context.newElement) {
    sizes.push(parseInt(context.newElement.css(dimension), 10));<commit_msg>position the dimming overlay based on the direction of the transition<commit_after>import { stop, animate, Promise, isAnimating, finish } from "liquid-fire";
import jQuery from "jquery";

export default function moveOverHalf(dimension, direction, opts) {
  var oldParams = {};
  var newParams = {};
  var overlayParams = {};
  var firstStep;
  var property;
  var measure;
  var elementToOverlay;

  var darkOpacity = 0.75;
  if (direction > 0) {
    // moving right
    overlayParams = {
      opacity: [0, darkOpacity]
    };
    elementToOverlay = this.newElement;
  } else {
    // moving left
    overlayParams = {
      opacity: [darkOpacity, 0]
    };
    elementToOverlay = this.oldElement;
  }

  var overlay = jQuery('<div class="transition-overlay"></div>');
  elementToOverlay.append(overlay);

  if (dimension.toLowerCase() === 'x') {
    property = 'translateX';
    measure = 'width';
  } else {
    property = 'translateY';
    measure = 'height';
  }

  if (isAnimating(this.oldElement, 'moving-in')) {
    firstStep = finish(this.oldElement, 'moving-in');
  } else {
    stop(this.oldElement);
    firstStep = Promise.resolve();
  }

  return firstStep.then(() => {
    var bigger = biggestSize(this, measure);

    this.oldElement[0].style.zIndex = direction > 0 ? 5 : 0;
    this.newElement[0].style.zIndex = direction > 0 ? 0 : 5;

    oldParams[property] = (bigger * (direction > 0 ? 1 : -0.5)) + 'px';
    newParams[property] = ["0px", (bigger * (direction > 0 ? -0.5 : 1)) + 'px'];

    return Promise.all([
      animate(overlay, overlayParams, opts),
      animate(this.oldElement, oldParams, opts),
      animate(this.newElement, newParams, opts, 'moving-in')
    ]).then(() => overlay.remove());
  });
}

function biggestSize(context, dimension) {
  var sizes = [];
  if (context.newElement) {
    sizes.push(parseInt(context.newElement.css(dimension), 10));
{'fraction_non_alphanumeric': 0.15577889447236182, 'fraction_numerical': 0.013958682300390842, 'mean_word_length': 3.2961630695443644, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 20, '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': '7468136', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1134, 'n_words': 273}