+0
Daily
5,944
stars
643
forks
186
watchers
69
prs
219
issues
2
releases
README
Snap.js
A Library for creating beautiful mobile shelfs in Javascript
View Video Preview
View Demos
Features
Support
Installation
Usage
Settings & Defaults
Public Methods
Gotchas
FAQ's
Compliments
Licensing
Extras
Features
Library Independent
High Customization
Flick Support
User Intent Detection
Disable Hyperextension
Event Hooks
CSS3 Powered Animations with IE fallbacks
Drag Support
Drag Handle Support
Programatic API
"No-Drag" Elements
Definable Easing Mode
Enable/Disable Events
Disabled Sides (left or right)
Supports Ratchet (with templates!)
Support
Firefox 10+
Wide Webkit Support (including Android WebKit 2.3.X)
IE 10
IE 9 Supports Toggling, Dragging but no Transitions
IE 7/8 Supports Toggling but no dragging or Transitions
Installation
As standalone just include the file in a script tag:
html
As a web component do:
shell
$ component install jakiestfu/Snap.js
Usage
javascript
var snapper = new Snap({
element: document.getElementById('content')
});
Settings and Defaults
javascript
settings = {
element: null,
dragger: null,
disable: 'none',
addBodyClasses: true,
hyperextensible: true,
resistance: 0.5,
flickThreshold: 50,
transitionSpeed: 0.3,
easing: 'ease',
maxPosition: 266,
minPosition: -266,
tapToClose: true,
touchToDrag: true,
slideIntent: 40,
minDragDistance: 5
}
element: The element which the user will be sliding side to side
dragger: The element which the user will be using to slide the target element side to side
disable: String, set to 'left' or 'right' to disable the respective side
addBodyClasses: Add classes to the body to signify which side is being opened
hyperextensible: If false, pane may not be slide past the minPosition and maxPosition
resistance: The cooeficcient used to slow sliding when user has passed max or min threshold
flickThreshold: Number of pixels the user needs to swiftly travel to activate a "flick" open
transitionSpeed: The speed at which the pane slides open or closed
easing: The CSS3 Easing method you want to use for transitions
maxPosition: Maximum number of pixels the pane may be slid to the right
minPosition: Maximum number of pixels the pane may be slid to the left
tapToClose: If true, tapping an open pane will close it
touchToDrag: If true, dragging the target settings.element will open/close the pane
minDragDistance: The minimum amount of pixels the user needs to drag within the slideIntent degrees to move the pane
slideIntent: The number of degrees the user must initiate sliding in towards the left or right (see diagram below)
Notes on Slide Intent: The slide intent is an int between 0 and 90, and represents the degrees in the first quadrant of a circle that you would like to have mirrored on the X and Y axis. For example, if you have 40 set as your slideIntent value, the user would only be able to slide the pane by dragging in the blue area in the diagram below. OnTop issues
#79Fixed positioning does not work21 comments · 2013-06-18#60iOS swipe left when opened moves whole screen19 comments · 2013-05-25#122Scrolling causes whole page to repaint18 comments · 2013-09-11#121Adding a fixed element to content container17 comments · 2013-09-10#115Slide Transition - Flicks (Draggy) - Any Tips/Tricks ?16 comments · 2013-08-27#108Phonegap , Annoying Horizontal Scroll16 comments · 2013-08-12#125Version 2.0 Roadmap13 comments · 2013-09-18#65Snap.js Modes: Reveal, Push, Over11 comments · 2013-06-04