mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-01-09 06:02:05 -05:00
Fix scroll speed on Firefox (#532)
Copied from https://github.com/LLK/scratch-blocks/pull/1427/
This commit is contained in:
parent
093c3d03bb
commit
0176dd7eed
1 changed files with 10 additions and 5 deletions
|
@ -213,6 +213,11 @@ class PaperCanvas extends React.Component {
|
|||
}
|
||||
}
|
||||
handleWheel (event) {
|
||||
// Multiplier variable, so that non-pixel-deltaModes are supported. Needed for Firefox.
|
||||
// See #529 (or LLK/scratch-blocks#1190).
|
||||
const multiplier = event.deltaMode === 0x1 ? 15 : 1;
|
||||
const deltaX = event.deltaX * multiplier;
|
||||
const deltaY = event.deltaY * multiplier;
|
||||
if (event.metaKey || event.ctrlKey) {
|
||||
// Zoom keeping mouse location fixed
|
||||
const canvasRect = this.canvas.getBoundingClientRect();
|
||||
|
@ -221,19 +226,19 @@ class PaperCanvas extends React.Component {
|
|||
const fixedPoint = paper.project.view.viewToProject(
|
||||
new paper.Point(offsetX, offsetY)
|
||||
);
|
||||
zoomOnFixedPoint(-event.deltaY / 100, fixedPoint);
|
||||
zoomOnFixedPoint(-deltaY / 100, fixedPoint);
|
||||
this.props.updateViewBounds(paper.view.matrix);
|
||||
this.props.setSelectedItems();
|
||||
} else if (event.shiftKey && event.deltaX === 0) {
|
||||
// Scroll horizontally (based on vertical scroll delta)
|
||||
// This is needed as for some browser/system combinations which do not set deltaX.
|
||||
// See #156.
|
||||
const dx = event.deltaY / paper.project.view.zoom;
|
||||
const dx = deltaY / paper.project.view.zoom;
|
||||
pan(dx, 0);
|
||||
this.props.updateViewBounds(paper.view.matrix);
|
||||
} else {
|
||||
const dx = event.deltaX / paper.project.view.zoom;
|
||||
const dy = event.deltaY / paper.project.view.zoom;
|
||||
const dx = deltaX / paper.project.view.zoom;
|
||||
const dy = deltaY / paper.project.view.zoom;
|
||||
pan(dx, dy);
|
||||
this.props.updateViewBounds(paper.view.matrix);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue