<commit_before>import { Component } from '@mycolorway/tao'
import $ from 'jquery'
import _ from 'lodash'

class SortableElement extends Component

  @tag 'tao-sortable'

  @attribute 'groupSelector'

  @attribute 'itemSelector', default: '[draggable="true"]'

  @attribute 'axis', default: 'y'

  _connected: ->
    @on 'dragstart', @itemSelector, (e) =>
      e.stopPropagation()
      $item = $ e.currentTarget
      itemRect = $item.get(0).getBoundingClientRect()
      @_startDragging $item

      e.originalEvent.dataTransfer.effectAllowed = 'move'
      e.originalEvent.dataTransfer.setData 'text/plain', 'tao-sortable'
      e.originalEvent.dataTransfer.setDragImage(
        @_sortingItem.get(0),
        e.clientX - itemRect.left,
        e.clientY - itemRect.top
      )
      null

  _disconnected: ->
    @off()
    $(document).off ".tao-sortable-#{@taoId}"

  _startDragging: ($item) ->
    @namespacedTrigger 'beforeSortStart', [$item]
    @_sortingItem = $item
    setTimeout -> $item.addClass('tao-sortable-sorting')
    @namespacedTrigger 'sortStart', [@_sortingItem]

    $(window).on "scroll.tao-sortable-#{@taoId}", _.throttle (e) =>
      @_expireDimensionCache()
      null<commit_msg>ADD: item handle selector option<commit_after>import { Component } from '@mycolorway/tao'
import $ from 'jquery'
import _ from 'lodash'

class SortableElement extends Component

  @tag 'tao-sortable'

  @attribute 'groupSelector'

  @attribute 'itemSelector', default: '[draggable="true"]'

  @attribute 'itemHandleSelector'

  @attribute 'axis', default: 'y'

  _connected: ->
    handleSelector = if @itemHandleSelector
      "#{@itemSelector} #{@itemHandleSelector}"
    else
      @itemSelector

    @on 'dragstart', handleSelector, (e) =>
      e.stopPropagation()
      $item = $(e.currentTarget).closest(@itemSelector)
      itemRect = $item.get(0).getBoundingClientRect()
      @_startDragging $item

      e.originalEvent.dataTransfer.effectAllowed = 'move'
      e.originalEvent.dataTransfer.setData 'text/plain', 'tao-sortable'
      e.originalEvent.dataTransfer.setDragImage(
        @_sortingItem.get(0),
        e.clientX - itemRect.left,
        e.clientY - itemRect.top
      )
      null

  _disconnected: ->
    @off()
    $(document).off ".tao-sortable-#{@taoId}"

  _startDragging: ($item) ->
    @namespacedTrigger 'beforeSortStart', [$item]
    @_sortingItem = $item
    setTimeout -> $item.addClass('tao-sortable-sorting')
    @namespacedTrigger 'sortStart', [@_sortingItem]

    $(window).on "scroll.tao-sortable-#{@taoId}", _.throttle (e) =>
      @_expireDimensionCache()
      null
{'fraction_non_alphanumeric': 0.14378585086042064, 'fraction_numerical': 0.0015296367112810707, 'mean_word_length': 3.441426146010187, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '231671', 'n_tokens_mistral': 875, 'n_tokens_neox': 857, 'n_words': 156}