Skip to content

Instantly share code, notes, and snippets.

@JBKahn
Created May 1, 2014 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JBKahn/5e5fd25a1f4871319863 to your computer and use it in GitHub Desktop.
Save JBKahn/5e5fd25a1f4871319863 to your computer and use it in GitHub Desktop.
Drag & Drop Attempt 2
handleDragEvent: (e, ui) =>
currentMousePosition = e.clientY
startingIndex = Collection.indexOf(currentlyDraggingData.model)
dragOverIndex = Collection.indexOf(@model)
currentIndexOfDraggingTransaction = Collection.indexOf(Collection.dragModel)
transactionTop = $($('.financial-transaction-item')[currentIndexOfDraggingTransaction]).offset().top - $(window).scrollTop()
if Collection.dragModel isnt @model
Collection.dragView.$el.detach()
if dragOverIndex > currentIndexOfDraggingTransaction
@$el.after(Collection.dragView.$el)
else
@$el.before(Collection.dragView.$el)
else
TransAbove = @$el.prev()
TransBelow = @$el.next()
Collection.dragView.$el.detach()
if currentMousePosition < transactionTop
TransBelow.after(Collection.dragView.$el)
else
TransAbove.before(Collection.dragView.$el)
startingIndex > dragOverIndex
movePosition = 'before'
else
movePosition ='after'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment