<commit_before>define(['jquery', 'net/meisen/general/Utility'], function ($, Utility) {

  var utilities = {
    createArrow: function(size, direction, click, theme) {
      var arrow = $(document.createElementNS('http://www.w3.org/2000/svg', 'g'));
      arrow.attr('class', 'gantt-scrollbar-arrow');
      
      el = $(document.createElementNS('http://www.w3.org/2000/svg', 'rect'));
      el.attr({ 'width': size, 'height': size, 'x': 0, y: 0, 'rx': 0, 'ry': 0 });
      el.css({ 'fill': theme.buttonColor, 'stroke': theme.buttonColorBorder, 'stroke-width': 1 });
      el.appendTo(arrow);
      
      el = $(document.createElementNS('http://www.w3.org/2000/svg', 'path'));
      if (direction == 'left') {
        el.attr({ 'd': 'M 8 4 L 8 10 5 7' });
      } else if (direction == 'right') {
        el.attr({ 'd': 'M 6 4 L 6 10 9 7' });
      } else if (direction == 'top') {
        el.attr({ 'd': 'M 4 8 L 10 8 7 5' });
      } else if (direction == 'bottom') {
        el.attr({ 'd': 'M 4 6 L 10 6 7 9' });
      }
      el.css({ 'fill': theme.arrowColor });
      el.appendTo(arrow);
      
      arrow.click(function() {
        if ($.isFunction(click)) {
          click({ direction: direction });
        }
      });
      
      return arrow
    }, 
    
    createScroll: function(scrollbar) {
      var _ref = this;
      
      return function(event) {
        
        var status = {
          anchor: scrollbar.type == 'horizontal' ? event.pageX : event.pageY,
          scrollbar: scrollbar
        };
                
        var moveHandler = function(event) {
          var isHorizontal = scrollbar.type == 'horizontal';
          var pos = isHorizontal ? event.pageX : event.pageY;
          var diff = pos - status.anchor;
          
          if (diff == 0) {
            return;
          } else {
            var direction = diff < 0 ? (isHorizontal ? 'left' : 'top') : (isHorizontal ? 'right' : 'bottom');
            diff = status.scrollbar.pixelToCoord(Math.abs(diff));
            status.scrollbar.move(direction, diff);
          }
          status.anchor = pos;
        };
        var disableHandler = function(event) {
          $(window).unbind('mousemove', moveHandler);
          $(window).unbind('mouseup', disableHandler);
        };
        
        $(window).bind('mousemove', moveHandler);
        $(window).bind('mouseup', disableHandler);
      };
    }
  };

  /*
   * Default constructor...
   */
  Scrollbar = function(type) {
    this.type = typeof(type) == 'undefined' || type == null ? 'horizontal' : type;
  };
  
  /*
   * Extended prototype
   */
  Scrollbar.prototype = {
    bar: null,
    scrollarea: null,
    marker: null,
    leftArrow: null,
    rightArrow: null,
    
    size: { height: 0, width: 0 },
    
    extent: 0,
    view: {
      position: 0,
      size: 0, 
      total: 0
    },
    
    defaultCfg: {
      theme: {
        arrowSize: 14,
        scrollareaColor: '#EEEEEE',
        markerColor: '#BFC8D1',
        buttonColorBorder: '#666666',
        arrowColor: '#666666',
        buttonColor: '#EBE7E8'
      },
      hideOnNoScroll: true,
      propagateScrollOnNoMove: false,
      step: 1
    },
    
    init: function(canvas, cfg) {
      var _ref = this;
            
      this.opts = $.extend(true, {}, this.defaultCfg, cfg);
      
      // create a group for the scrollbar
      this.bar = $(document.createElementNS('http://www.w3.org/2000/svg', 'g'));
      this.bar.attr('class', 'gantt-scrollbar-container');
      
      // create the scrollbar
      var extentAttribute = this.type == 'horizontal' ? 'height' : 'width';
      this.scrollarea = $(document.createElementNS('http://www.w3.org/2000/svg', 'rect'));
      this.scrollarea.attr({ y: 0, 'rx': 0, 'ry': 0 });
      this.scrollarea.attr(extentAttribute, this.getFixedExtent());
      this.scrollarea.css({ 'fill': this.opts.theme.scrollareaColor, 'stroke': this.opts.theme.scrollareaColor, 'stroke-width': 1 });
      this.scrollarea.appendTo(this.bar);
      this.scrollarea.click(function(event) {
        var pos = this.type == 'horizontal' ? event.offsetX : event.offsetY;
        
        var coord = _ref.pixelToCoord(pos - _ref.opts.theme.arrowSize - 1);
        var direction;
        if (this.type == 'horizontal') {
          direction = coord < _ref.view.position ? 'left' : 'right';
        } else {
          direction = coord < _ref.view.position ? 'top' : 'bottom';
        }<commit_msg>- fixed a bug with the click on the scrollbar, moving in the wrong direction<commit_after>define(['jquery', 'net/meisen/general/Utility'], function ($, Utility) {

  var utilities = {
    createArrow: function(size, direction, click, theme) {
      var arrow = $(document.createElementNS('http://www.w3.org/2000/svg', 'g'));
      arrow.attr('class', 'gantt-scrollbar-arrow');
      
      el = $(document.createElementNS('http://www.w3.org/2000/svg', 'rect'));
      el.attr({ 'width': size, 'height': size, 'x': 0, y: 0, 'rx': 0, 'ry': 0 });
      el.css({ 'fill': theme.buttonColor, 'stroke': theme.buttonColorBorder, 'stroke-width': 1 });
      el.appendTo(arrow);
      
      el = $(document.createElementNS('http://www.w3.org/2000/svg', 'path'));
      if (direction == 'left') {
        el.attr({ 'd': 'M 8 4 L 8 10 5 7' });
      } else if (direction == 'right') {
        el.attr({ 'd': 'M 6 4 L 6 10 9 7' });
      } else if (direction == 'top') {
        el.attr({ 'd': 'M 4 8 L 10 8 7 5' });
      } else if (direction == 'bottom') {
        el.attr({ 'd': 'M 4 6 L 10 6 7 9' });
      }
      el.css({ 'fill': theme.arrowColor });
      el.appendTo(arrow);
      
      arrow.click(function() {
        if ($.isFunction(click)) {
          click({ direction: direction });
        }
      });
      
      return arrow
    }, 
    
    createScroll: function(scrollbar) {
      var _ref = this;
      
      return function(event) {
        
        var status = {
          anchor: scrollbar.type == 'horizontal' ? event.pageX : event.pageY,
          scrollbar: scrollbar
        };
                
        var moveHandler = function(event) {
          var isHorizontal = scrollbar.type == 'horizontal';
          var pos = isHorizontal ? event.pageX : event.pageY;
          var diff = pos - status.anchor;
          
          if (diff == 0) {
            return;
          } else {
            var direction = diff < 0 ? (isHorizontal ? 'left' : 'top') : (isHorizontal ? 'right' : 'bottom');
            diff = status.scrollbar.pixelToCoord(Math.abs(diff));
            status.scrollbar.move(direction, diff);
          }
          status.anchor = pos;
        };
        var disableHandler = function(event) {
          $(window).unbind('mousemove', moveHandler);
          $(window).unbind('mouseup', disableHandler);
        };
        
        $(window).bind('mousemove', moveHandler);
        $(window).bind('mouseup', disableHandler);
      };
    }
  };

  /*
   * Default constructor...
   */
  Scrollbar = function(type) {
    this.type = typeof(type) == 'undefined' || type == null ? 'horizontal' : type;
  };
  
  /*
   * Extended prototype
   */
  Scrollbar.prototype = {
    bar: null,
    scrollarea: null,
    marker: null,
    leftArrow: null,
    rightArrow: null,
    
    size: { height: 0, width: 0 },
    
    extent: 0,
    view: {
      position: 0,
      size: 0, 
      total: 0
    },
    
    defaultCfg: {
      theme: {
        arrowSize: 14,
        scrollareaColor: '#EEEEEE',
        markerColor: '#BFC8D1',
        buttonColorBorder: '#666666',
        arrowColor: '#666666',
        buttonColor: '#EBE7E8'
      },
      hideOnNoScroll: true,
      propagateScrollOnNoMove: false,
      step: 1
    },
    
    init: function(canvas, cfg) {
      var _ref = this;
            
      this.opts = $.extend(true, {}, this.defaultCfg, cfg);
      
      // create a group for the scrollbar
      this.bar = $(document.createElementNS('http://www.w3.org/2000/svg', 'g'));
      this.bar.attr('class', 'gantt-scrollbar-container');
      
      // create the scrollbar
      var extentAttribute = this.type == 'horizontal' ? 'height' : 'width';
      this.scrollarea = $(document.createElementNS('http://www.w3.org/2000/svg', 'rect'));
      this.scrollarea.attr({ y: 0, 'rx': 0, 'ry': 0 });
      this.scrollarea.attr(extentAttribute, this.getFixedExtent());
      this.scrollarea.css({ 'fill': this.opts.theme.scrollareaColor, 'stroke': this.opts.theme.scrollareaColor, 'stroke-width': 1 });
      this.scrollarea.appendTo(this.bar);
      this.scrollarea.click(function(event) {
        var offset = _ref.bar.offset();
        var pos = _ref.type == 'horizontal' ? event.pageX - offset.left : event.pageY - offset.top;       
        var coord = _ref.pixelToCoord(pos - (_ref.getFixedExtent() + 1));

        var direction;
        if (this.type == 'horizontal') {
          direction = coord < _ref.view.position ? 'left' : 'right';
        } else {
          direction = coord < _ref.view.position ? 'top' : 'bottom';
        }
{'fraction_non_alphanumeric': 0.16222197631957508, 'fraction_numerical': 0.019918114418501717, 'mean_word_length': 2.063728813559322, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 10, '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': '2753010', 'n_tokens_mistral': 2947, 'n_tokens_neox': 2789, 'n_words': 641}