Sencha Environment Detection offers a wide range with simple tools.
Instead of Ext.os.is.Tablet, you can make life easier with Ext.os.deviceType , which will return:
NB: this value can also be corrupted by adding "? DeviceType =" to the URL.
http:
Ext.os.name returns a single element:
- IOS
- Android
- WebOS
- Blackberry
- RIMTablet
- MacOS
- for windows
- Linux
- Bada
- Other
The usual browser discovery ability is available through Ext.browser.name .
Something that I just recently encountered that I like is a feature detection that allows you to encode, similar to Modernizr / YepNope, based on the ability of the device. Ext.feature offers:
- Ext.feature.has.Audio
- Ext.feature.has.Canvas
- Ext.feature.has.ClassList
- Ext.feature.has.CreateContextualFragment
- Ext.feature.has.Css3dTransforms
- Ext.feature.has.CssAnimations
- Ext.feature.has.CssTransforms
- Ext.feature.has.CssTransitions
- Ext.feature.has.DeviceMotion
- Ext.feature.has.Geolocation
- Ext.feature.has.History
- Ext.feature.has.Orientation
- Ext.feature.has.OrientationChange
- Ext.feature.has.Range
- Ext.feature.has.SqlDatabase
- Ext.feature.has.Svg
- Ext.feature.has.Touch
- Ext.feature.has.Video
- Ext.feature.has.Vml
- Ext.feature.has.WebSockets
To detect fullscreen / browser / home screen mode in iOS:
window.navigator.standalone == true
Orientation Ext.device.Orientation and change orientation:
Ext.device.Orientation.on({ scope: this, orientationchange: function(e) { console.log('Alpha: ', e.alpha); console.log('Beta: ', e.beta); console.log('Gamma: ', e.gamma); } });
Orientation is based on Viewport. I usually add a more reliable listener:
onOrientationChange: function(viewport, orientation, width, height) { // test trigger and values console.log('o:' + orientation + ' w:' + width + ' h:' + height); if (width > height) { orientation = 'landscape'; } else { orientation = 'portrait'; } // add handlers here... }
greg.arnott
source share