<commit_before>import {DOM} from "aurelia-pal";
import {customAttribute, bindable} from "aurelia-templating";
import {inject, transient} from "aurelia-dependency-injection";
import {oribella, matchesSelector} from "oribella-default-gestures";

@customAttribute("sortable")
@inject(DOM.Element)
@transient()
export class Sortable {

  @bindable scroll = null;
  @bindable scrollSpeed = 10;
  @bindable scrollSensitivity = 10;
  @bindable items = [];
  @bindable placeholder = { placeholderClass: "placeholder", style: {} };
  @bindable axis = "";
  @bindable moved = () => {};
  @bindable dragZIndex = 1;
  @bindable disallowedDragTagNames = ["INPUT", "SELECT", "TEXTAREA"];
  @bindable allowDrag = args => {
    if(this.disallowedDragTagNames.indexOf(args.event.target.tagName) !== -1) {
      return false;
    }
    if(args.event.target.isContentEditable) {
      return false;
    }
    return true;
  };
  @bindable allowMove = () => { return true; };

  constructor(element) {
    this.element = element;
    this.selector = "[sortable-item]";
    /*this.options = {
      strategy: STRATEGY_FLAG.REMOVE_IF_POINTERS_GT
    };*/
    this.fromIx = -1;
    this.toIx = -1;
    this.dragX = 0;
    this.dragY = 0;
    this.isAutoScrollingX = false;
    this.isAutoScrollingY = false;
  }
  bindScroll(scroll, fn) {
    scroll.addEventListener("scroll", fn, false);
    return () => {
      scroll.removeEventListener("scroll", fn, false);
    };
  }
  activate() {
    this.removeListener = oribella.on(this.element, "swipe", this);
    if(typeof this.scroll === "string") {
      this.scroll = this.closest(this.element, this.scroll, document);
    }
    if(!(this.scroll instanceof Element)) {
      this.scroll = this.element;
    }
  }
  deactivate() {
    this.removeListener();
  }
  attached() {
    this.activate();
  }
  detached() {
    if(typeof this.removeListener === "function") {
      this.removeListener();
    }
  }
  dragStyle() {
    var style = {};
    style.position = this.dragElement.style.position;
    style.left = this.dragElement.style.left;
    style.top = this.dragElement.style.top;
    style.width = this.dragElement.style.width;
    style.height = this.dragElement.style.height;
    style.pointerEvents = this.dragElement.style.pointerEvents;
    style.zIndex = this.dragElement.style.zIndex;<commit_msg>fix(sortable): use DOM.Element instead of Element<commit_after>import {DOM} from "aurelia-pal";
import {customAttribute, bindable} from "aurelia-templating";
import {inject, transient} from "aurelia-dependency-injection";
import {oribella, matchesSelector} from "oribella-default-gestures";

@customAttribute("sortable")
@inject(DOM.Element)
@transient()
export class Sortable {

  @bindable scroll = null;
  @bindable scrollSpeed = 10;
  @bindable scrollSensitivity = 10;
  @bindable items = [];
  @bindable placeholder = { placeholderClass: "placeholder", style: {} };
  @bindable axis = "";
  @bindable moved = () => {};
  @bindable dragZIndex = 1;
  @bindable disallowedDragTagNames = ["INPUT", "SELECT", "TEXTAREA"];
  @bindable allowDrag = args => {
    if(this.disallowedDragTagNames.indexOf(args.event.target.tagName) !== -1) {
      return false;
    }
    if(args.event.target.isContentEditable) {
      return false;
    }
    return true;
  };
  @bindable allowMove = () => { return true; };

  constructor(element) {
    this.element = element;
    this.selector = "[sortable-item]";
    /*this.options = {
      strategy: STRATEGY_FLAG.REMOVE_IF_POINTERS_GT
    };*/
    this.fromIx = -1;
    this.toIx = -1;
    this.dragX = 0;
    this.dragY = 0;
    this.isAutoScrollingX = false;
    this.isAutoScrollingY = false;
  }
  bindScroll(scroll, fn) {
    scroll.addEventListener("scroll", fn, false);
    return () => {
      scroll.removeEventListener("scroll", fn, false);
    };
  }
  activate() {
    this.removeListener = oribella.on(this.element, "swipe", this);
    if(typeof this.scroll === "string") {
      this.scroll = this.closest(this.element, this.scroll, document);
    }
    if(!(this.scroll instanceof DOM.Element)) {
      this.scroll = this.element;
    }
  }
  deactivate() {
    this.removeListener();
  }
  attached() {
    this.activate();
  }
  detached() {
    if(typeof this.removeListener === "function") {
      this.removeListener();
    }
  }
  dragStyle() {
    var style = {};
    style.position = this.dragElement.style.position;
    style.left = this.dragElement.style.left;
    style.top = this.dragElement.style.top;
    style.width = this.dragElement.style.width;
    style.height = this.dragElement.style.height;
    style.pointerEvents = this.dragElement.style.pointerEvents;
    style.zIndex = this.dragElement.style.zIndex;
{'fraction_non_alphanumeric': 0.14821882951653945, 'fraction_numerical': 0.004240882103477523, 'mean_word_length': 3.408411214953271, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '7610912', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1530, 'n_words': 286}