mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
Added scroll delta mode constants.
This commit is contained in:
@@ -304,6 +304,32 @@ Blockly.utils.mouseToSvg = function(e, svg, matrix) {
|
||||
return svgPoint.matrixTransform(matrix);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the scroll delta of a mouse event in pixel units.
|
||||
* @param {!Event} e Mouse event.
|
||||
* @return {{x: number, y: number}} Scroll delta object with .x and .y
|
||||
* properties.
|
||||
*/
|
||||
Blockly.utils.getScrollDeltaPixels = function(e) {
|
||||
switch (e.deltaMode) {
|
||||
case 0x00: // Pixel mode.
|
||||
return {
|
||||
x: e.deltaX,
|
||||
y: e.deltaY
|
||||
};
|
||||
case 0x01: // Line mode.
|
||||
return {
|
||||
x: e.deltaX * Blockly.LINE_MODE_MULTIPLIER,
|
||||
y: e.deltaY * Blockly.LINE_MODE_MULTIPLIER
|
||||
};
|
||||
case 0x02: // Page mode.
|
||||
return {
|
||||
x: e.deltaX * Blockly.PAGE_MODE_MULTIPLIER,
|
||||
y: e.deltaY * Blockly.PAGE_MODE_MULTIPLIER
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Given an array of strings, return the length of the shortest one.
|
||||
* @param {!Array.<string>} array Array of strings.
|
||||
|
||||
Reference in New Issue
Block a user