Merge ol.pointer.CLONE_PROPS and CLONE_DEFAULTS into a single array

This commit is contained in:
Tom Payne
2014-03-12 17:14:44 +01:00
committed by tsauerwein
parent 5a358918e1
commit df71854561
+33 -72
View File
@@ -209,12 +209,12 @@ ol.pointer.PointerEventHandler.prototype.removeEvents_ = function(events) {
ol.pointer.PointerEventHandler.prototype.cloneEvent = ol.pointer.PointerEventHandler.prototype.cloneEvent =
function(browserEvent, inEvent) { function(browserEvent, inEvent) {
var eventCopy = {}, p; var eventCopy = {}, p;
for (var i = 0; i < ol.pointer.CLONE_PROPS.length; i++) { for (var i = 0, ii = ol.pointer.CLONE_PROPS.length; i < ii; i++) {
p = ol.pointer.CLONE_PROPS[i]; p = ol.pointer.CLONE_PROPS[i][0];
eventCopy[p] = eventCopy[p] =
browserEvent[p] || browserEvent[p] ||
inEvent[p] || inEvent[p] ||
ol.pointer.CLONE_DEFAULTS[i]; ol.pointer.CLONE_PROPS[i][1];
} }
return eventCopy; return eventCopy;
@@ -455,79 +455,40 @@ ol.pointer.EventType = {
/** /**
* List of properties to copy when cloning an event. * Properties to copy when cloning an event, with default values.
* @type {Array.<string>} * @type {Array.<Array>}
*/ */
ol.pointer.CLONE_PROPS = [ ol.pointer.CLONE_PROPS = [
// MouseEvent // MouseEvent
'bubbles', ['bubbles', false],
'cancelable', ['cancelable', false],
'view', ['view', null],
'detail', ['detail', null],
'screenX', ['screenX', 0],
'screenY', ['screenY', 0],
'clientX', ['clientX', 0],
'clientY', ['clientY', 0],
'ctrlKey', ['ctrlKey', false],
'altKey', ['altKey', false],
'shiftKey', ['shiftKey', false],
'metaKey', ['metaKey', false],
'button', ['button', 0],
'relatedTarget', ['relatedTarget', null],
// DOM Level 3 // DOM Level 3
'buttons', ['buttons', 0],
// PointerEvent // PointerEvent
'pointerId', ['pointerId', 0],
'width', ['width', 0],
'height', ['height', 0],
'pressure', ['pressure', 0],
'tiltX', ['tiltX', 0],
'tiltY', ['tiltY', 0],
'pointerType', ['pointerType', ''],
'hwTimestamp', ['hwTimestamp', 0],
'isPrimary', ['isPrimary', false],
// event instance // event instance
'type', ['type', ''],
'target', ['target', null],
'currentTarget', ['currentTarget', null],
'which' ['which', 0]
];
/**
* List of default values when cloning an event.
*/
ol.pointer.CLONE_DEFAULTS = [
// MouseEvent
false,
false,
null,
null,
0,
0,
0,
0,
false,
false,
false,
false,
0,
null,
// DOM Level 3
0,
// PointerEvent
0,
0,
0,
0,
0,
0,
'',
0,
false,
// event instance
'',
null,
null,
0
]; ];