2016-11-26 01:28:53 +00:00
|
|
|
var OS = require('./OS');
|
|
|
|
var Browser = require('./Browser');
|
|
|
|
|
2016-11-25 04:00:15 +00:00
|
|
|
var Input = {
|
|
|
|
|
2017-08-01 12:10:08 +00:00
|
|
|
// @property {boolean} touch - Is touch available?
|
2016-11-25 04:00:15 +00:00
|
|
|
touch: false,
|
|
|
|
|
2017-08-01 12:10:08 +00:00
|
|
|
// @property {boolean} mspointer - Is mspointer available?
|
2016-11-25 04:00:15 +00:00
|
|
|
mspointer: false,
|
|
|
|
|
2017-08-01 12:10:08 +00:00
|
|
|
// @property {?string} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll'
|
2016-11-25 04:00:15 +00:00
|
|
|
wheelEvent: null
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-11-26 01:28:53 +00:00
|
|
|
function init ()
|
2016-11-25 04:00:15 +00:00
|
|
|
{
|
|
|
|
if ('ontouchstart' in document.documentElement || (window.navigator.maxTouchPoints && window.navigator.maxTouchPoints >= 1))
|
|
|
|
{
|
|
|
|
Input.touch = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window.navigator.msPointerEnabled || window.navigator.pointerEnabled)
|
|
|
|
{
|
|
|
|
Input.mspointer = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!OS.cocoonJS)
|
|
|
|
{
|
|
|
|
// See https://developer.mozilla.org/en-US/docs/Web/Events/wheel
|
|
|
|
if ('onwheel' in window || (Browser.ie && 'WheelEvent' in window))
|
|
|
|
{
|
|
|
|
// DOM3 Wheel Event: FF 17+, IE 9+, Chrome 31+, Safari 7+
|
|
|
|
Input.wheelEvent = 'wheel';
|
|
|
|
}
|
|
|
|
else if ('onmousewheel' in window)
|
|
|
|
{
|
|
|
|
// Non-FF legacy: IE 6-9, Chrome 1-31, Safari 5-7.
|
|
|
|
Input.wheelEvent = 'mousewheel';
|
|
|
|
}
|
|
|
|
else if (Browser.firefox && 'MouseScrollEvent' in window)
|
|
|
|
{
|
|
|
|
// FF prior to 17. This should probably be scrubbed.
|
|
|
|
Input.wheelEvent = 'DOMMouseScroll';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Input;
|
|
|
|
}
|
|
|
|
|
2016-11-26 01:28:53 +00:00
|
|
|
module.exports = init();
|