<commit_before>"use strict";

$(document).ready(function () {
  function PanoramaWidget() {
    var widget = this;
    var slider = $(".image-slider");
    var img = slider.children(".cropped").children("img");
    var lastPageX = 0, lastPageY = 0, firstDrag = true;

    this.drag = function (event) {
      if (firstDrag) {
        lastPageX = event.pageX;
        lastPageY = event.pageY;
        firstDrag = false;
      }

      var diffX = lastPageX - event.pageX;
      var diffY = lastPageY - event.pageY;

      this.moveX(diffX);
      this.moveY(diffY);

      lastPageX = event.pageX;
      lastPageY = event.pageY;
    }

    this.moveX = function (delta) {
      this.move("margin-left", delta);
    }

    this.moveY = function (delta) {
      this.move("margin-top", delta);
    }

    this.move = function (direction, delta) {
      var mt = parseInt(img.css(direction));
      var val = mt - delta;
      if (val > 0) val = 0;
      img.css(direction, val + "px");
    }

    this.registerEvents = function () {
      var drag = function(event){
        widget.drag(event);
      }

      slider.on("dragstart", function () {
        return false;
      });

      slider.on("mousedown", function () {
        slider.on("mousemove", drag);
        firstDrag = true;
        return false;
      });

      slider.on("mouseup", function () {
        slider.off("mousemove", drag);
        firstDrag = false;
      });

      slider.on("mouseout", function () {
        slider.off("mousemove", drag);
        firstDrag = false;
      });
    }
  }

  var w = new PanoramaWidget();
  w.registerEvents();<commit_msg>avoid overflow<commit_after>"use strict";

$(document).ready(function () {
  function PanoramaWidget() {
    var widget = this;
    var slider = $(".image-slider");
    var cropped = slider.children(".cropped");
    var img = cropped.children("img");
    var lastPageX = 0, lastPageY = 0, firstDrag = true;

    this.drag = function (event) {
      if (firstDrag) {
        lastPageX = event.pageX;
        lastPageY = event.pageY;
        firstDrag = false;
      }

      var diffX = lastPageX - event.pageX;
      var diffY = lastPageY - event.pageY;

      this.moveX(diffX);
      this.moveY(diffY);

      lastPageX = event.pageX;
      lastPageY = event.pageY;
    }

    this.moveX = function (delta) {
      var max = cropped.width() - img.width();
      this.move("margin-left", delta, max);
    }

    this.moveY = function (delta) {
      var max = cropped.height() - img.height();
      this.move("margin-top", delta, max);
    }

    this.move = function (direction, delta, max) {
      var mt = parseInt(img.css(direction));
      var val = mt - delta;
      if (val > 0) val = 0;
      if (val < max) val = max;
      img.css(direction, val + "px");
    }

    this.registerEvents = function () {
      var drag = function (event) {
        widget.drag(event);
      }

      slider.on("dragstart", function () {
        return false;
      });

      slider.on("mousedown", function () {
        slider.on("mousemove", drag);
        firstDrag = true;
        return false;
      });

      slider.on("mouseup", function () {
        slider.off("mousemove", drag);
        firstDrag = false;
      });

      slider.on("mouseout", function () {
        slider.off("mousemove", drag);
        firstDrag = false;
      });
    }
  }

  var w = new PanoramaWidget();
  w.registerEvents();
{'fraction_non_alphanumeric': 0.14922763042844653, 'fraction_numerical': 0.002331681725444477, 'mean_word_length': 2.0974729241877257, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, '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': '3065013', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1073, 'n_words': 240}