ViewportStateManager
Observe changes in the viewport and adapt your UIs accordingly.
Usage
Browserify
Viewport State Manager can be consumed as a CommonJS module using browserify.
npm install viewport-state-manager
var ViewportStateManager = ; var manager = ranges: desktop: 1025 5000 tablet: 768 1024 handheld: 1 767 { // ... };
RequireJS
ViewportStateManager is AMD compliant, so you can use it with require.js.
// Configure RequireJsrequirejs; ;
Global
Options
ranges (breakpoints)
Type: Object
// key – breakpoint name // value – min, max array of pixel dimensions tablet: 768 1024
- default –
desktop: [1025, 5000], tablet: [768, 1024], handheld: [1, 767]
callback
Function to be invoked each time a breakpoint threshold is crossed
Type: Function
{ /* ... */ };
currentState
- Type: String - The name of the breakpoint you are currently inpreviousState
- Type: String - The name of the breakpoint you exited from
debounceTime
Duration of debounce set on the window resize
or orientationchange
events
Type: Number
- default:
250
currentViewportState
The default viewport state. Note: This will automatically be set on instantiation if no argument is supplied
Type: String
- default:
''
Browser Compatibility
IE9+, Chrome, Firefox, Safari, Android 2.3+, iOS 5+. You know, the good stuff!