Heuristically determine the pointer accuracy — 'coarse' or 'fine' — for a device/ user agent.
The 'pointer' media query as defined in level 4 (http://dev.w3.org/csswg/mediaqueries4/#pointer) can provide a valuable indication for responsive decision making for rendering of input widgets but also content in general. For example a date picker widget might be rendered in a touch or mouse/ stylus optimized way. Because the W3C recommendation is currently in draft status, and browser support is naturally low we've created this library.
The classifier uses the following two properties of the current device to make a decision:
- Pointer media query result
- Touch input capability
Some of these properties cannot reliably determined — "best effort" is the right way to deal with this.
The algorithm then is:
- If the pointer media query is supported, and the result is not 'none', use it
- If the device supports touch input, use 'coarse'
- Otherwise, use 'fine'
See demo (http://n-fuse.github.com/pointeraccuracy.js/demo.html)
- ES5
Object.create()
polyfill must exist for older browsers. window.matchMedia
polyfill must exist for older browsers.