mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 07:22:33 -05:00
29 lines
663 B
JavaScript
29 lines
663 B
JavaScript
|
class MouseWheel {
|
||
|
constructor (runtime) {
|
||
|
/**
|
||
|
* Reference to the owning Runtime.
|
||
|
* @type{!Runtime}
|
||
|
*/
|
||
|
this.runtime = runtime;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Mouse wheel DOM event handler.
|
||
|
* @param {object} data Data from DOM event.
|
||
|
*/
|
||
|
postData (data) {
|
||
|
const matchFields = {};
|
||
|
if (data.deltaY < 0) {
|
||
|
matchFields.KEY_OPTION = 'up arrow';
|
||
|
} else if (data.deltaY > 0) {
|
||
|
matchFields.KEY_OPTION = 'down arrow';
|
||
|
} else {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
this.runtime.startHats('event_whenkeypressed', matchFields);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = MouseWheel;
|