forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserSelect.js
More file actions
32 lines (27 loc) · 843 Bytes
/
Copy pathUserSelect.js
File metadata and controls
32 lines (27 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Sets the user-select property on the canvas style. Can be used to disable default browser selection actions.
*
* @method Phaser.Canvas.setUserSelect
* @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
* @param {string} [value] - The touch action to set. Defaults to 'none'.
* @return {HTMLCanvasElement} The source canvas.
*/
var UserSelect = function (canvas, value)
{
if (value === undefined) { value = 'none'; }
var vendors = [
'-webkit-',
'-khtml-',
'-moz-',
'-ms-',
''
];
vendors.forEach(function (vendor)
{
canvas.style[vendor + 'user-select'] = value;
});
canvas.style['-webkit-touch-callout'] = value;
canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)';
return canvas;
};
module.exports = UserSelect;