diff --git a/src/renderview.js b/src/renderview.js index 61b2808..c90e18e 100644 --- a/src/renderview.js +++ b/src/renderview.js @@ -394,7 +394,7 @@ class BaseRenderView { if (isVisible !== this._isVisible) { this._isVisible = isVisible const event = { - event_type: isVisible ? 'show' : 'hide', + type: isVisible ? 'show' : 'hide', t: getTimestamp() } this.onEvent(event) @@ -456,12 +456,12 @@ class BaseRenderView { this._lsize = [logicalWidth, logicalHeight] const event = { - event_type: 'resize', + type: 'resize', width: logicalWidth, height: logicalHeight, pwidth: physicalWidth, pheight: physicalHeight, - pixel_ratio: ratio, + pixelratio: ratio, timestamp: getTimestamp() } this.onEvent(event) @@ -501,7 +501,7 @@ class BaseRenderView { lastButtons = buttons const event = { - event_type: 'pointer_down', + type: 'pointer_down', x: ev.offsetX, y: ev.offsetY, button, @@ -552,7 +552,7 @@ class BaseRenderView { pendingMoveEvent.y = ev.offsetY } else { const event = { - event_type: 'pointer_move', + type: 'pointer_move', x: ev.offsetX, y: ev.offsetY, button, @@ -587,7 +587,7 @@ class BaseRenderView { lastButtons = buttons const event = { - event_type: 'pointer_up', + type: 'pointer_up', x: ev.offsetX, y: ev.offsetY, button, @@ -616,7 +616,7 @@ class BaseRenderView { button = 0 const event = { - event_type: 'pointer_enter', + type: 'pointer_enter', x: ev.offsetX, y: ev.offsetY, button, @@ -645,7 +645,7 @@ class BaseRenderView { button = 0 const event = { - event_type: 'pointer_leave', + type: 'pointer_leave', x: ev.offsetX, y: ev.offsetY, button, @@ -675,7 +675,7 @@ class BaseRenderView { const modifiers = getModifiers(ev) const event = { - event_type: 'double_click', + type: 'double_click', x: ev.offsetX, y: ev.offsetY, button, @@ -729,7 +729,7 @@ class BaseRenderView { pendingWheelEvent.dy += ev.deltaY * scale } else { const event = { - event_type: 'wheel', + type: 'wheel', x: ev.offsetX, y: ev.offsetY, dx: ev.deltaX * scale, @@ -766,7 +766,7 @@ class BaseRenderView { const modifiers = getModifiers(ev) const event = { - event_type: 'key_down', + type: 'key_down', key: KEY_MAP[ev.key] || ev.key, modifiers, timestamp: getTimestamp() @@ -784,7 +784,7 @@ class BaseRenderView { const modifiers = getModifiers(ev) const event = { - event_type: 'key_up', + type: 'key_up', key: KEY_MAP[ev.key] || ev.key, modifiers, timestamp: getTimestamp() @@ -805,7 +805,7 @@ class BaseRenderView { } const event = { - event_type: 'char', + type: 'char', data: ev.data, is_composing: ev.isComposing, input_type: ev.inputType, diff --git a/src/spec.md b/src/spec.md index e014db7..52ad3ef 100644 --- a/src/spec.md +++ b/src/spec.md @@ -65,12 +65,12 @@ This event is emitted when the canvas changes size. Fields: -* `event_type`: 'resize' +* `type`: 'resize' * `width`: The width in logical pixels. * `height`: The height in logical pixels. * `pwidth`: The width in physical pixels. * `pheight`: The height in physical pixels. -* `pixel_ratio`: The pixel ratio between logical and physical pixels. +* `pixelratio`: The pixel ratio between logical and physical pixels. * `timestamp`: A timestamp in seconds. @@ -80,7 +80,7 @@ This event is emitted when the canvas is closed (i.e. destroyed). Fields: -* `event_type`: 'close' +* `type`: 'close' * `timestamp`: A timestamp in seconds. @@ -92,7 +92,7 @@ shown. If this is not the case, the implementation should emit a 'hide' event. Fields: -* `event_type`: 'show' +* `type`: 'show' * `timestamp`: A timestamp in seconds. @@ -102,7 +102,7 @@ This event is emitted when the canvas is hidden. It can e.g. be minimized or scr Fields: -* `event_type`: 'hide' +* `type`: 'hide' * `timestamp`: A timestamp in seconds. @@ -112,7 +112,7 @@ This event is emitted when the user interacts with mouse, touch or other pointer Fields: -* `event_type`: 'pointer_down' +* `type`: 'pointer_down' * `x`: The horizontal position of the pointer within the canvas. * `y`: The vertical position of the pointer within the canvas. * `button`: The button to which this event applies. @@ -139,7 +139,7 @@ This event is emitted when the user releases a pointer. Fields: -* `event_type`: 'pointer_up' +* `type`: 'pointer_up' * ... the other fields are the same as the pointer_down event. @@ -151,7 +151,7 @@ In remote contexts it is recommended to throttle this event to avoid spamming th Fields: -* `event_type`: 'pointer_move' +* `type`: 'pointer_move' * ... the other fields are the same as the pointer_down event. @@ -161,7 +161,7 @@ This event is emitted when the user moves a pointer into the boundary of the can Fields: -* `event_type`: 'pointer_enter' +* `type`: 'pointer_enter' * `timestamp`: A timestamp in seconds. @@ -171,7 +171,7 @@ This event is emitted when the user moves a pointer out of the boundary of the c Fields: -* `event_type`: 'pointer_enter' +* `type`: 'pointer_enter' * `timestamp`: A timestamp in seconds. @@ -181,7 +181,7 @@ This event is emitted on a double-click. Fields: -* `event_type`: 'pointer_down' +* `type`: 'pointer_down' * `x`: The horizontal position of the pointer within the canvas. * `y`: The vertical position of the pointer within the canvas. * `button`: The button to which this event applies. @@ -198,7 +198,7 @@ In remote contexts it is recommended to throttle this event to avoid spamming th Fields: -* `event_type`: 'wheel' +* `type`: 'wheel' * `dx`: The horizontal scroll delta (positive means scroll right). * `dy`: The vertical scroll delta (positive means scroll down or zoom out). * `x`: The mouse horizontal position during the scroll. @@ -227,7 +227,7 @@ This event is emitted when a key is pressed down. Fields: -* `event_type`: 'key_down' +* `type`: 'key_down' * `key`: The key being pressed as a string. * `modifiers`: A tuple of modifier keys being pressed down. * `timestamp`: A timestamp in seconds. @@ -244,7 +244,7 @@ The key names follow the [browser spec](https://developer.mozilla.org/en-US/docs This event is emitted when a key is released. -* `event_type`: 'key_up' +* `type`: 'key_up' * `key`: The key being released as a string. * `modifiers`: A tuple of modifier keys being pressed down. * `timestamp`: A timestamp in seconds. diff --git a/src/tester.html b/src/tester.html index 7e940ad..4feaa22 100644 --- a/src/tester.html +++ b/src/tester.html @@ -31,14 +31,14 @@ const events = this._events this._eventCount += 1 - if (events.length > 0 && events[0].event_type == event.event_type) { + if (events.length > 0 && events[0].type == event.type) { events[0] = event } else { events.unshift(event) this._events = this._events.slice(0, 32) } - if (event.event_type == 'resize') { + if (event.type == 'resize') { this.viewElement.width = event.pwidth this.viewElement.height = event.pheight }