<commit_before>'use strict';

export default class Izitin {
  constructor({
    fraction = 0,
    fn = null,
    container = document,
    items = '.izitin',
    stagger = 100,
    css = true,
    remove = false,
    throttle = 0
  } = {}) {
    this.fraction = Math.max(Math.min(+fraction, 1), 0);
    this.fn = fn;
    this.container = container instanceof Node ? container : document.querySelector(container);
    this.items = items;
    this.stagger = +stagger;
    this.css = !!css;
    this.remove = !!remove;
    this.throttle = +throttle;
    this.init();
  }
  init() {
    this.lastPosition = window.pageYOffset || document.documentElement.scrollTop;
    // this.handler();
    if (!this.isInitialized) {
      if (this.throttle) {
        this._handler = this.throttling(this.handler.bind(this), this.throttle).bind(this);
      }
      else {
        this._handler = this.handler.bind(this);
      }
      window.addEventListener('scroll', this._handler);
      window.addEventListener('load', this._handler);
      window.addEventListener('resize', this._handler);
      this.isInitialized = true;
    }
  }
  handler(e) {
    const curPosition = window.pageYOffset || document.documentElement.scrollTop;
    let count = 0;
    let items = this.container.querySelectorAll(this.items);
    if (this.lastPosition > curPosition) {
      items = [].slice.call(items, 0).reverse();
    }
    items.forEach(item => {
      let rect;
      let wWidth;
      let wHeight;
      let position;
      let itizin;

      try {
        rect = item.getBoundingClientRect();
        wWidth = window.innerWidth;
        wHeight = window.innerHeight;
        position = {
          above: rect.top < 0 && rect.bottom <= 0,
          left: rect.left < 0 && rect.right <= 0,
          right: rect.left >= wWidth && rect.right > wWidth,
          below: rect.top >= wHeight && rect.bottom > wHeight,
        };

        if (this.fraction) {
          const heightFraction = Math.min(rect.height, wHeight) * this.fraction;
          const widthFraction = Math.min(rect.width, wWidth) * this.fraction;
          itizin =  (
                      (rect.top <= wHeight - heightFraction && rect.bottom > 0) ||
                      (rect.top < wHeight && rect.bottom >= heightFraction && rect.bottom <= wHeight)
                    ) &&
                    (
                      (rect.left <= wWidth - widthFraction && rect.right > 0) ||
                      (rect.left < wWidth && rect.right >= widthFraction && rect.right <= wWidth)
                    );
        }
        else {
          itizin =  rect.top < wHeight &&
                    rect.bottom > 0 &&
                    rect.left < wWidth &&
                    rect.right > 0;
        }

        if (itizin) {
          if (this.stagger && !item.classList.contains('itizin')) {
            if (this.css) {
              item.style.transitionDelay = `${this.stagger * count}ms`;
              item.classList.add('itizin');
            }
            else {
              setTimeout(() => {
                item.classList.add('itizin');
              }, this.stagger * count);
            }
            count++;
          }
          else {
            item.classList.add('itizin');
          }
        }
        else if (this.remove) {
          item.style.transitionDelay = '';
          item.classList.remove('itizin');
        }
        else {
          item.style.transitionDelay = '';
        }


        if (position.above) {
          item.classList.add('izitin-above');
        }
        else {
          item.classList.remove('izitin-above');
        }<commit_msg>remove transition-delay when not staggering<commit_after>'use strict';

export default class Izitin {
  constructor({
    fraction = 0,
    fn = null,
    container = document,
    items = '.izitin',
    stagger = 100,
    css = true,
    remove = false,
    throttle = 0
  } = {}) {
    this.fraction = Math.max(Math.min(+fraction, 1), 0);
    this.fn = fn;
    this.container = container instanceof Node ? container : document.querySelector(container);
    this.items = items;
    this.stagger = +stagger;
    this.css = !!css;
    this.remove = !!remove;
    this.throttle = +throttle;
    this.init();
  }
  init() {
    this.lastPosition = window.pageYOffset || document.documentElement.scrollTop;
    // this.handler();
    if (!this.isInitialized) {
      if (this.throttle) {
        this._handler = this.throttling(this.handler.bind(this), this.throttle).bind(this);
      }
      else {
        this._handler = this.handler.bind(this);
      }
      window.addEventListener('scroll', this._handler);
      window.addEventListener('load', this._handler);
      window.addEventListener('resize', this._handler);
      this.isInitialized = true;
    }
  }
  handler(e) {
    const curPosition = window.pageYOffset || document.documentElement.scrollTop;
    let count = 0;
    let items = this.container.querySelectorAll(this.items);
    if (this.lastPosition > curPosition) {
      items = [].slice.call(items, 0).reverse();
    }
    items.forEach(item => {
      let rect;
      let wWidth;
      let wHeight;
      let position;
      let itizin;

      try {
        rect = item.getBoundingClientRect();
        wWidth = window.innerWidth;
        wHeight = window.innerHeight;
        position = {
          above: rect.top < 0 && rect.bottom <= 0,
          left: rect.left < 0 && rect.right <= 0,
          right: rect.left >= wWidth && rect.right > wWidth,
          below: rect.top >= wHeight && rect.bottom > wHeight,
        };

        if (this.fraction) {
          const heightFraction = Math.min(rect.height, wHeight) * this.fraction;
          const widthFraction = Math.min(rect.width, wWidth) * this.fraction;
          itizin =  (
                      (rect.top <= wHeight - heightFraction && rect.bottom > 0) ||
                      (rect.top < wHeight && rect.bottom >= heightFraction && rect.bottom <= wHeight)
                    ) &&
                    (
                      (rect.left <= wWidth - widthFraction && rect.right > 0) ||
                      (rect.left < wWidth && rect.right >= widthFraction && rect.right <= wWidth)
                    );
        }
        else {
          itizin =  rect.top < wHeight &&
                    rect.bottom > 0 &&
                    rect.left < wWidth &&
                    rect.right > 0;
        }

        if (itizin) {
          if (this.stagger && !item.classList.contains('itizin')) {
            if (this.css) {
              item.style.transitionDelay = `${this.stagger * count}ms`;
              item.classList.add('itizin');
            }
            else {
              setTimeout(() => {
                item.classList.add('itizin');
              }, this.stagger * count);
            }
            count++;
          }
          else {
            item.style.transitionDelay = '';
            item.classList.add('itizin');
          }
        }
        else if (this.remove) {
          item.style.transitionDelay = '';
          item.classList.remove('itizin');
        }
        else {
          item.style.transitionDelay = '';
        }


        if (position.above) {
          item.classList.add('izitin-above');
        }
        else {
          item.classList.remove('izitin-above');
        }
{'fraction_non_alphanumeric': 0.13330604448082958, 'fraction_numerical': 0.004639104925637877, 'mean_word_length': 1.6761591821832786, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, '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': '1299681', 'n_tokens_mistral': 2162, 'n_tokens_neox': 2097, 'n_words': 407}