Skip to content

Commit

Permalink
fix d&d
Browse files Browse the repository at this point in the history
  • Loading branch information
niquola committed Apr 1, 2013
1 parent 0b5b507 commit 1d2364c
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions app/assets/javascripts/calendars.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,26 @@ window.CalendarCnt = ($scope, $routeParams, $http)->

window.myapp.
directive 'draggable', ($document)->
startX=0
startY=0
x = 0
y = 0
return (scope, element, attr)->
startX=0
startY=0
x = 0
y = 0
mousemove = (event)->
y = event.screenY - startY
x = event.screenX - startX
element.css(top: y + 'px', left: x + 'px')
dy = event.screenY - startY
dx = event.screenX - startX
element.css(top: y + dy + 'px', left: x + dx + 'px')

mouseup = ()->
$document.unbind('mousemove', mousemove)
$document.unbind('mouseup', mouseup)
element.css
position: 'absolute',
cursor: 'pointer'

element.bind 'mousedown', (event)->
startX = event.screenX - x
startY = event.screenY - y
element.css(position: 'absolute', cursor: 'pointer')
position = element.position()
y = position.top
x = position.left
startX = event.screenX
startY = event.screenY
$document.bind('mousemove', mousemove)
$document.bind('mouseup', mouseup)

0 comments on commit 1d2364c

Please sign in to comment.