Skip to content

Instantly share code, notes, and snippets.

@ionoy
Created October 3, 2012 17:10
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 ionoy/3828373 to your computer and use it in GitHub Desktop.
Save ionoy/3828373 to your computer and use it in GitHub Desktop.
[Unit]
class Draggable
{
public OffsetX : int { get; set; }
public OffsetY : int { get; set; }
public this(moveHandler = null, downHandler = null, upHandler = null)
{}
public Handler() : void
{
event mousedown( c ) {
downHandler(c);
event mousemove( m ) {
moveHandler( m )
OffsetX = c.posx - m.posx;
OffsetY = c.posy - m.posy;
} until mouseup ( u ) {
upHandler( u );
}
}
}
}
[Page]
class Page
{
public DivDraggable : Draggable { get; set; }
<div bind="$DivDraggable.Handler" style-left="$(DivDraggable.OffsetX)" />
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment