Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/renderview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -501,7 +501,7 @@ class BaseRenderView {
lastButtons = buttons

const event = {
event_type: 'pointer_down',
type: 'pointer_down',
x: ev.offsetX,
y: ev.offsetY,
button,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -587,7 +587,7 @@ class BaseRenderView {
lastButtons = buttons

const event = {
event_type: 'pointer_up',
type: 'pointer_up',
x: ev.offsetX,
y: ev.offsetY,
button,
Expand Down Expand Up @@ -616,7 +616,7 @@ class BaseRenderView {
button = 0

const event = {
event_type: 'pointer_enter',
type: 'pointer_enter',
x: ev.offsetX,
y: ev.offsetY,
button,
Expand Down Expand Up @@ -645,7 +645,7 @@ class BaseRenderView {
button = 0

const event = {
event_type: 'pointer_leave',
type: 'pointer_leave',
x: ev.offsetX,
y: ev.offsetY,
button,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -805,7 +805,7 @@ class BaseRenderView {
}

const event = {
event_type: 'char',
type: 'char',
data: ev.data,
is_composing: ev.isComposing,
input_type: ev.inputType,
Expand Down
28 changes: 14 additions & 14 deletions src/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand All @@ -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.


Expand All @@ -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.


Expand All @@ -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.


Expand All @@ -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.
Expand All @@ -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.


Expand All @@ -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.


Expand All @@ -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.


Expand All @@ -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.


Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/tester.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading