Skip to content

Commit ff29c1e

Browse files
authored
Rename event_type -> type, pixel_ratio -> pixelratio (#6)
* Rename event_type -> type, pixel_ratio -> pixelratio * standard
1 parent 3f45538 commit ff29c1e

3 files changed

Lines changed: 29 additions & 29 deletions

File tree

src/renderview.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ class BaseRenderView {
394394
if (isVisible !== this._isVisible) {
395395
this._isVisible = isVisible
396396
const event = {
397-
event_type: isVisible ? 'show' : 'hide',
397+
type: isVisible ? 'show' : 'hide',
398398
t: getTimestamp()
399399
}
400400
this.onEvent(event)
@@ -456,12 +456,12 @@ class BaseRenderView {
456456
this._lsize = [logicalWidth, logicalHeight]
457457

458458
const event = {
459-
event_type: 'resize',
459+
type: 'resize',
460460
width: logicalWidth,
461461
height: logicalHeight,
462462
pwidth: physicalWidth,
463463
pheight: physicalHeight,
464-
pixel_ratio: ratio,
464+
pixelratio: ratio,
465465
timestamp: getTimestamp()
466466
}
467467
this.onEvent(event)
@@ -501,7 +501,7 @@ class BaseRenderView {
501501
lastButtons = buttons
502502

503503
const event = {
504-
event_type: 'pointer_down',
504+
type: 'pointer_down',
505505
x: ev.offsetX,
506506
y: ev.offsetY,
507507
button,
@@ -552,7 +552,7 @@ class BaseRenderView {
552552
pendingMoveEvent.y = ev.offsetY
553553
} else {
554554
const event = {
555-
event_type: 'pointer_move',
555+
type: 'pointer_move',
556556
x: ev.offsetX,
557557
y: ev.offsetY,
558558
button,
@@ -587,7 +587,7 @@ class BaseRenderView {
587587
lastButtons = buttons
588588

589589
const event = {
590-
event_type: 'pointer_up',
590+
type: 'pointer_up',
591591
x: ev.offsetX,
592592
y: ev.offsetY,
593593
button,
@@ -616,7 +616,7 @@ class BaseRenderView {
616616
button = 0
617617

618618
const event = {
619-
event_type: 'pointer_enter',
619+
type: 'pointer_enter',
620620
x: ev.offsetX,
621621
y: ev.offsetY,
622622
button,
@@ -645,7 +645,7 @@ class BaseRenderView {
645645
button = 0
646646

647647
const event = {
648-
event_type: 'pointer_leave',
648+
type: 'pointer_leave',
649649
x: ev.offsetX,
650650
y: ev.offsetY,
651651
button,
@@ -675,7 +675,7 @@ class BaseRenderView {
675675
const modifiers = getModifiers(ev)
676676

677677
const event = {
678-
event_type: 'double_click',
678+
type: 'double_click',
679679
x: ev.offsetX,
680680
y: ev.offsetY,
681681
button,
@@ -729,7 +729,7 @@ class BaseRenderView {
729729
pendingWheelEvent.dy += ev.deltaY * scale
730730
} else {
731731
const event = {
732-
event_type: 'wheel',
732+
type: 'wheel',
733733
x: ev.offsetX,
734734
y: ev.offsetY,
735735
dx: ev.deltaX * scale,
@@ -766,7 +766,7 @@ class BaseRenderView {
766766
const modifiers = getModifiers(ev)
767767

768768
const event = {
769-
event_type: 'key_down',
769+
type: 'key_down',
770770
key: KEY_MAP[ev.key] || ev.key,
771771
modifiers,
772772
timestamp: getTimestamp()
@@ -784,7 +784,7 @@ class BaseRenderView {
784784
const modifiers = getModifiers(ev)
785785

786786
const event = {
787-
event_type: 'key_up',
787+
type: 'key_up',
788788
key: KEY_MAP[ev.key] || ev.key,
789789
modifiers,
790790
timestamp: getTimestamp()
@@ -805,7 +805,7 @@ class BaseRenderView {
805805
}
806806

807807
const event = {
808-
event_type: 'char',
808+
type: 'char',
809809
data: ev.data,
810810
is_composing: ev.isComposing,
811811
input_type: ev.inputType,

src/spec.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ This event is emitted when the canvas changes size.
6565

6666
Fields:
6767

68-
* `event_type`: 'resize'
68+
* `type`: 'resize'
6969
* `width`: The width in logical pixels.
7070
* `height`: The height in logical pixels.
7171
* `pwidth`: The width in physical pixels.
7272
* `pheight`: The height in physical pixels.
73-
* `pixel_ratio`: The pixel ratio between logical and physical pixels.
73+
* `pixelratio`: The pixel ratio between logical and physical pixels.
7474
* `timestamp`: A timestamp in seconds.
7575

7676

@@ -80,7 +80,7 @@ This event is emitted when the canvas is closed (i.e. destroyed).
8080

8181
Fields:
8282

83-
* `event_type`: 'close'
83+
* `type`: 'close'
8484
* `timestamp`: A timestamp in seconds.
8585

8686

@@ -92,7 +92,7 @@ shown. If this is not the case, the implementation should emit a 'hide' event.
9292

9393
Fields:
9494

95-
* `event_type`: 'show'
95+
* `type`: 'show'
9696
* `timestamp`: A timestamp in seconds.
9797

9898

@@ -102,7 +102,7 @@ This event is emitted when the canvas is hidden. It can e.g. be minimized or scr
102102

103103
Fields:
104104

105-
* `event_type`: 'hide'
105+
* `type`: 'hide'
106106
* `timestamp`: A timestamp in seconds.
107107

108108

@@ -112,7 +112,7 @@ This event is emitted when the user interacts with mouse, touch or other pointer
112112

113113
Fields:
114114

115-
* `event_type`: 'pointer_down'
115+
* `type`: 'pointer_down'
116116
* `x`: The horizontal position of the pointer within the canvas.
117117
* `y`: The vertical position of the pointer within the canvas.
118118
* `button`: The button to which this event applies.
@@ -139,7 +139,7 @@ This event is emitted when the user releases a pointer.
139139

140140
Fields:
141141

142-
* `event_type`: 'pointer_up'
142+
* `type`: 'pointer_up'
143143
* ... the other fields are the same as the pointer_down event.
144144

145145

@@ -151,7 +151,7 @@ In remote contexts it is recommended to throttle this event to avoid spamming th
151151

152152
Fields:
153153

154-
* `event_type`: 'pointer_move'
154+
* `type`: 'pointer_move'
155155
* ... the other fields are the same as the pointer_down event.
156156

157157

@@ -161,7 +161,7 @@ This event is emitted when the user moves a pointer into the boundary of the can
161161

162162
Fields:
163163

164-
* `event_type`: 'pointer_enter'
164+
* `type`: 'pointer_enter'
165165
* `timestamp`: A timestamp in seconds.
166166

167167

@@ -171,7 +171,7 @@ This event is emitted when the user moves a pointer out of the boundary of the c
171171

172172
Fields:
173173

174-
* `event_type`: 'pointer_enter'
174+
* `type`: 'pointer_enter'
175175
* `timestamp`: A timestamp in seconds.
176176

177177

@@ -181,7 +181,7 @@ This event is emitted on a double-click.
181181

182182
Fields:
183183

184-
* `event_type`: 'pointer_down'
184+
* `type`: 'pointer_down'
185185
* `x`: The horizontal position of the pointer within the canvas.
186186
* `y`: The vertical position of the pointer within the canvas.
187187
* `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
198198

199199
Fields:
200200

201-
* `event_type`: 'wheel'
201+
* `type`: 'wheel'
202202
* `dx`: The horizontal scroll delta (positive means scroll right).
203203
* `dy`: The vertical scroll delta (positive means scroll down or zoom out).
204204
* `x`: The mouse horizontal position during the scroll.
@@ -227,7 +227,7 @@ This event is emitted when a key is pressed down.
227227

228228
Fields:
229229

230-
* `event_type`: 'key_down'
230+
* `type`: 'key_down'
231231
* `key`: The key being pressed as a string.
232232
* `modifiers`: A tuple of modifier keys being pressed down.
233233
* `timestamp`: A timestamp in seconds.
@@ -244,7 +244,7 @@ The key names follow the [browser spec](https://developer.mozilla.org/en-US/docs
244244

245245
This event is emitted when a key is released.
246246

247-
* `event_type`: 'key_up'
247+
* `type`: 'key_up'
248248
* `key`: The key being released as a string.
249249
* `modifiers`: A tuple of modifier keys being pressed down.
250250
* `timestamp`: A timestamp in seconds.

src/tester.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
const events = this._events
3232
this._eventCount += 1
3333

34-
if (events.length > 0 && events[0].event_type == event.event_type) {
34+
if (events.length > 0 && events[0].type == event.type) {
3535
events[0] = event
3636
} else {
3737
events.unshift(event)
3838
this._events = this._events.slice(0, 32)
3939
}
4040

41-
if (event.event_type == 'resize') {
41+
if (event.type == 'resize') {
4242
this.viewElement.width = event.pwidth
4343
this.viewElement.height = event.pheight
4444
}

0 commit comments

Comments
 (0)