<commit_before>(function (exports) {

  var scrollEvents = "scroll.lock-on touchmove.lock-on mousedown.lock-on wheel.lock-on DOMMouseScroll.lock-on mousewheel.lock-on keyup.lock-on";

  var LockOn = function(selector, options) {
    this.selector = selector;
    this.options = options || {};
  };

  LockOn.prototype.elementTop = function() {
    var offsetCalculator = this.options.offsetCalculator;
    return $(this.selector).offset().top - (offsetCalculator ? offsetCalculator() : 0);
  };

  LockOn.prototype.lock = function() {
    var self = this,
        previousTop = this.elementTop(),
        startedAt = new Date().getTime()
        i = 0;

    $(window).scrollTop(previousTop);

    var interval = setInterval(function() {
      i = i + 1;

      var top = self.elementTop(),
          scrollTop = $(window).scrollTop();

      if ((top !== previousTop) || (scrollTop !== top)) {
        $(window).scrollTop(top);
        previousTop = top;
      }

      // We commit suicide after 1s just to clean up<commit_msg>BUGFIX: Fix issues if the DOM element is destroyed while the interval is ongoing (in particular this was weird for Firefox)<commit_after>(function (exports) {

  var scrollEvents = "scroll.lock-on touchmove.lock-on mousedown.lock-on wheel.lock-on DOMMouseScroll.lock-on mousewheel.lock-on keyup.lock-on";

  var LockOn = function(selector, options) {
    this.selector = selector;
    this.options = options || {};
  };

  LockOn.prototype.elementTop = function() {
    var offsetCalculator = this.options.offsetCalculator,
        selected = $(this.selector);

    if (selected && selected.offset && selected.offset()) {
      return selected.offset().top - (offsetCalculator ? offsetCalculator() : 0);
    }
  };

  LockOn.prototype.lock = function() {
    var self = this,
        previousTop = this.elementTop(),
        startedAt = new Date().getTime()
        i = 0;

    $(window).scrollTop(previousTop);

    var interval = setInterval(function() {
      i = i + 1;

      var top = self.elementTop(),
          scrollTop = $(window).scrollTop();

      if (typeof(top) === "undefined") {
        $('body,html').off(scrollEvents)
        clearInterval(interval);
        return;
      }

      if ((top !== previousTop) || (scrollTop !== top)) {
        $(window).scrollTop(top);
        previousTop = top;
      }

      // We commit suicide after 1s just to clean up
{'fraction_non_alphanumeric': 0.13851913477537436, 'fraction_numerical': 0.0033277870216306157, 'mean_word_length': 2.7933753943217665, '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': '6185046', 'n_tokens_mistral': 724, 'n_tokens_neox': 684, 'n_words': 171}