-
Notifications
You must be signed in to change notification settings - Fork 16
/
snap.js.javascript.txt
78 lines (69 loc) · 6.15 KB
/
snap.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
SNAP.JS
VERSION ==> #1.9.2
new Snap(OBJ) #Creates a "mobile shelf" panel, that appears on both sides.
#Structure must be:
# .snap-drawers // Panels
# .snap-drawer .snap-drawer-left
# .snap-drawer .snap-drawer-right
# .snap-content // Non-panels
#snap.css assigns requires CSS, but can be tweaked. Also defines CSS on html, body that
#might be removed. Applies default width of 266px to panels.
#OBJ:
# - element ELEM: .snap-content
# - dragger ELEM (def: body): element that gets the swipe events
# - disable "left|right": disable one side.
# - addBodyClasses (def: true): add classes "snapjs-left|right" to body
# - hyperextensible (def: true): if false, max. width of the menu impossible to extend
# beyond min|maxPosition
# - min|maxPosition (def: -266|266): should be .snap-drawer width
# - resistance (def: 0.5): slows dragging when beyond min|maxDistance. Higger is slower.
# - transitionSpeed (def: 0.3): speed factor at which the panel opens
# - easing (def: "ease"): CSS3 easing method
# - tapToClose BOOL (def: true): tap the panel closes it
# - touchToDrag BOOL (def: true): dragging the panel opens it. If false, must be
# JavaScript API only.
# - slideIntent NUM (def: 40): moves the pane when swipping within NUM degrees of horizontal
# line, for minDragDistance pixels
# - minDragDistance NUM (def: 5)
#Returns SNAPPER
SNAPPER.settings(OBJ) #Modifies constructor OBJ (element and touchToDrag are read-only)
SNAPPER.state() #Returns OBJ:
# - state "closed|left|right"
# - info:
# - opening "left|right": which panel is moving
# - towards "left|right": direction of the mouse
# - hyperExtending BOOL: true if dragging beyong bounds
# - halfway BOOL: at least halfway open
# - translation:
# - absolute NUM: pixels moves towards left|right
# - sinceDirectionChange NUM: same but reset after each mouse direction change
# - percentage NUM: percentage pane is open
SNAPPER.open("left|right") #
SNAPPER.expand("left|right") #As opposed to open(), makes panel cover whole screen
SNAPPER.close() #
SNAPPER.enable|disable() #
SNAPER.on("start|drag|end",FUNC())#When starting moving, while moving, stop moving the pane.
SNAPPER.on("open", FUNC()) #On SNAPPER.open()
SNAPPER.on("close", FUNC()) #On SNAPPER.close() or tapToClose
SNAPPER.on("expandLeft|Right",
FUNC()) #On SNAPPER.expand("left|right")
SNAPER.on("enable|disable",FUNC())#On SNAPPER.enable|disable()
data-snap-ignore="true" #HTML attribute that makes element ignore Snap.js.
SNAPPER.on("ignore", FUNC()) #
ANGULAR SNAP ==> #Angular wrapper. MODULE is "snap".
# - <snap-drawers>: instead of .snap-drawers
# - <ELEM snap-drawer[="left|right"]>: instead of .snap-drawer.
# Wrap in .snap-drawers if missing.
# - <snap-content[ snap-options="OBJ" or snap-opt-VAR="VAL"]>: instead of .snap-content
# Can also use snapRemoteProvider.globalOptions OBJ for options.
# snap-options $watch() for OBJ changes.
# - <snap-toggle[ snap-side="left|right"]>: calls SNAPPER.open()
# - <snap-close>: calls SNAPPER.close()
# - <snap-dragger>: adds as dragger option
# - snapRemote SERVICE: with methods getSnapper(), toggle|open|expand(["left|right"]),
# close(), enable|disable()
#Use snap-id="'ID'" HTML attribute with snap-toggle|close|content if several sets of shelves,
#also last argument ID to snapRemote.FUNC()
#Includes CSS