-
Notifications
You must be signed in to change notification settings - Fork 16
/
hammer.js.javascript.txt
99 lines (92 loc) · 7.74 KB
/
hammer.js.javascript.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
HAMMER.JS
new Hammer[.Manager](ELEM[, OBJ]) #Returns HAMMER.
#Makes ELEM catch mobile events. By def. includes tap, press, swipe, pan, pinch, rotate.
#OBJ (def: Hammer.defaults):
# - touchAction "compute|auto|pan-x|pan-y|none" (def: "compute"): CSS touch-action
# property. "compute" means letting Hammer.js define defaults.
# - domEvents BOOL (def: false): if true, emits DOM events (a bit slower)
# - enable BOOL|FUNC(RECOGNIZER, ELEM)->BOOL (def: true)
# - cssProps OBJ: CSS properties added to ELEM to improve event detection.
# Def: content-zooming, tap-highlight-color, touch-callout, touch-select, user-drag,
# user-select
# - present OBJ_ARR
# - recognizers ARR_ARR: only with ".Manager" (otherwise use Hammer.defaults.preset)
# Each ARR is [ RECOGNIZER[_STR], OBJ2, RECOGNIZER[_STR]_ARR ]. OBJ2 are options.
#Should use <meta name="viewport" content="user-scalable=no, width=device-width,
#initial-scale=1, maximum-scale=1"> too
#Version 2.0.4
HAMMER.set(OBJ) #Change option
HAMMER.on("EVENT ...",FUNC(...)) #event has properties:
# - type RECOGNIZER_STR
# - deltaX|Y NUM: pixels since first move
# - deltaTime NUM: time since first move
# - distance NUM
# - angle NUM
# - velocity[X|Y]: in pixels/ms
# - direction|offsetDirection: from last|first position.
# Can be Hammer.DIRECTION_NONE|LEFT|RIGHT|UP|DOWN|HORIZONTAL|VERTICAL|ALL (binary flags)
# - scale NUM: for multitouch
# - rotation NUM: for multitouch
# - center OBJ: center position in multitouch
# - srcEvent EVENT: TouchEvent, MouseEvent or PointerEvent
# - target ELEM
# - pointerType "touch|mouse|pen|kinect"
# - eventType: Can be INPUT_START|MOVE|END|CANCEL
# - isFirst|Final BOOL
# - pointers OBJ_ARR
# - changedPointers OBJ_ARR
HAMER.off("EVENT ..."[,FUNC(...)])#
HAMMER.stop() #
HAMMER.destroy() #
new Hammer.Recognizer(OBJ) #Returns RECOGNIZER. Catch a specific event. Custom ones should not be needed unless
#(see online doc then) need combination of events together, failovers or repetitions
#(e.g. triple taps).
#OBJ:
# - event RECOGNIZER_STR
# - pointers NUM
#Builtin RECOGNIZER:
# - "tap". EVENT.tapCount NUM is the number of taps. OBJ:
# - taps NUM (def: 1): number of taps
# - interval NUM (def: 300): max time between two taps if multiple tap
# - time NUM (def: 250): max press time
# - threshold NUM (def: 2): max move
# - posThreshold NUM (def: 10): max move between two taps
# - "doubletap": like "tap" but with def. taps 2
# - "press[up]". Holding a tap. OBJ:
# - threshold NUM (def: 5): max move
# - time NUM (def: 500)
# - "swipe[left|right|up|down]": by def. only horizontal. OBJ:
# - threshold NUM (def: 10): min move
# - velocity NUM (def: 0.65, in px/ms): min. speed
# - direction Hammer.DIRECTION_*
# - "pan[start|move|end|cancel|left|right|up|down]": by def. only horizontal.
# (Should keep vertical for scrolling). As opposed to "swipe", continous dragging. OBJ:
# - threshold NUM (def: 10)
# - direction Hammer.DIRECTION_*
# - "pinch[start|move|end|cancel|in|out]". OBJ:
# - threshold NUM (def: 10)
# - "rotate[start|move|end|cancel]". OBJ:
# - threshold NUM (def: 0): min. rotation
RECOGNIZER.set(OBJ) #Change options
HAMMER.get(RECOGNIZER[_STR]) #
HAMMER.add|remove
(RECOGNIZER[_STR][_ARR]) #
JQ.hammer(OBJ) #jQuery wrapper. Uses jquery.hammer.js 2.0.0
ANGULAR HAMMER ==> #Version 2.1.10. MODULE "hmTouchEvents"
#Creates directives:
# - hm-EVENT="EXPR" (e.g. hm-Pinchmove):
# - each ELEM has its own HAMMER.
# - EVENT can be "custom" meaning, it is defined according to hm-recognizer-options,
# which must at least define event and type.
# Useful for combined events, etc.
# - hm-manager-options="OBJ_EXPR"
# - hm-recognizer-options="OBJ_[ARR_]EXPR". OBJ also has:
# - preventDefault BOOL, stopPropagation BOOL
# - type RECOGNIZER_STR: to differentiate options if several EVENTS on same ELEM,
# or to use with hm-custom
#DIRECTION_* must be written "DIRECTION_*|..." (pipe-separated).
HAMMER.JS TOUCH EMULATOR ==> #Emulates mobile events on desktop by preventing and chaning mouse* events.
#Use shift for multitouch events.
#Version 0.0.2