Permalink
Browse files

Add simple event abstraction

  • Loading branch information...
Koen Bok
Koen Bok committed Apr 30, 2013
1 parent 524606a commit a85039b1dcbcbe3b0595a8b0b0ed7c3b32258657
Showing with 31 additions and 61 deletions.
  1. +31 −61 src/primitives/events.coffee
@@ -1,64 +1,34 @@
Class =
UIEvent: "UIEvent"
FocusEvent: "FocusEvent"
MouseEvent: "MouseEvent"
TouchEvent: "TouchEvent"
WheelEvent: "WheelEvent"
TextEvent: "TextEvent"
KeyboardEvent: "KeyboardEvent"
CompositionEvent: "CompositionEvent"
MutationEvent: "MutationEvent"
MutationNameEvent: "MutationNameEvent"
CustomEvent: "CustomEvent"
TransitionEvent: "TransitionEvent"
_ = require "underscore"
Types =
DOMActivate: Class.UIEvent
load: Class.UIEvent
unload: Class.UIEvent
abort: Class.UIEvent
error: Class.UIEvent
select: Class.UIEvent
resize: Class.UIEvent
scroll: Class.UIEvent
blur: Class.FocusEvent
DOMFocusIn: Class.FocusEvent
DOMFocusOut: Class.FocusEvent
focus: Class.FocusEvent
focusin: Class.FocusEvent
focusout: Class.FocusEvent
click: Class.MouseEvent
dblclick: Class.MouseEvent
mousedown: Class.MouseEvent
mouseenter: Class.MouseEvent
mouseleave: Class.MouseEvent
mousemove: Class.MouseEvent
mouseover: Class.MouseEvent
mouseout: Class.MouseEvent
mouseup: Class.MouseEvent
touchstart: Class.TouchEvent
touchmove: Class.TouchEvent
touchend: Class.TouchEvent
touchcancel: Class.TouchEvent
wheel: Class.WheelEvent
textinput: Class.TextEvent
keydown: Class.KeyboardEvent
keypress: Class.KeyboardEvent
keyup: Class.KeyboardEvent
compositionstart: Class.CompositionEvent
compositionupdate: Class.CompositionEvent
compositionend: Class.CompositionEvent
DOMAttrModified: Class.MutationEvent
DOMCharacterDataModified: Class.MutationEvent
DOMNodeInserted: Class.MutationEvent
DOMNodeInsertedIntoDocument: Class.MutationEvent
DOMNodeRemoved: Class.MutationEvent
DOMNodeRemovedFromDocument: Class.MutationEvent
DOMSubtreeModified: Class.MutationEvent
DOMAttributeNameChanged: Class.MutationNameEvent
DOMElementNameChanged: Class.MutationNameEvent
transitionend: Class.TransitionEvent
utils = require "../utils"
exports.EventClass = Class
exports.EventTypes = Types
Events = {}
if utils.isTouch()
Events.TouchStart = "touchstart"
Events.TouchEnd = "touchend"
Events.TouchMove = "touchmove"
else
Events.TouchStart = "mousedown"
Events.TouchEnd = "mouseup"
Events.TouchMove = "mousemove"
# Standard dom events
Events.MouseOver = "mouseover"
Events.MouseOut = "mouseout"
# Specific Framer events
Events.DragStart = "dragstart"
Events.DragMove = "dragmove"
Events.DragEnd = "dragend"
Events.sanitize = (event) ->
touchEvent = event.touches?[0]
touchEvent ?= event.changedTouches?[0]
touchEvent ?= event
touchEvent
exports.Events = Events

0 comments on commit a85039b

Please sign in to comment.