mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2025-08-01 16:58:47 -04:00
Merge pull request #479 from yueyuzhao/issue/473-drag-with-mouse-with-grid-on
Drag sprite with a mouse/trackpad with grid turned on
This commit is contained in:
commit
918c42a56f
2 changed files with 18 additions and 24 deletions
|
@ -5,7 +5,7 @@
|
|||
import ScratchJr from '../ScratchJr';
|
||||
import Events from '../../utils/Events';
|
||||
import Localization from '../../utils/Localization';
|
||||
import {gn, scaleMultiplier, isTablet, newDiv, setProps, newP, newCanvas} from '../../utils/lib';
|
||||
import {gn, scaleMultiplier, newDiv, setProps, newP, newCanvas} from '../../utils/lib';
|
||||
|
||||
let width = 482;
|
||||
let height = 362;
|
||||
|
@ -69,15 +69,12 @@ export default class Grid {
|
|||
ctx.stroke();
|
||||
dy += size;
|
||||
}
|
||||
if (isTablet) {
|
||||
cnv.ontouchstart = function (evt) {
|
||||
ScratchJr.stage.mouseDown(evt);
|
||||
};
|
||||
} else {
|
||||
cnv.onmousedown = function (evt) {
|
||||
ScratchJr.stage.mouseDown(evt);
|
||||
};
|
||||
}
|
||||
cnv.ontouchstart = function (evt) {
|
||||
ScratchJr.stage.mouseDown(evt);
|
||||
};
|
||||
cnv.onmousedown = function (evt) {
|
||||
ScratchJr.stage.mouseDown(evt);
|
||||
};
|
||||
}
|
||||
|
||||
static createNumbering (w, h) {
|
||||
|
@ -153,15 +150,12 @@ export default class Grid {
|
|||
var cnv = newCanvas(gc, 0, 0, size + 2, size + 2, {
|
||||
position: 'absolute'
|
||||
});
|
||||
if (isTablet) {
|
||||
cnv.ontouchstart = function (evt) {
|
||||
Grid.mouseDownOnCursor(evt);
|
||||
};
|
||||
} else {
|
||||
cnv.onmousedown = function (evt) {
|
||||
Grid.mouseDownOnCursor(evt);
|
||||
};
|
||||
}
|
||||
cnv.ontouchstart = function (evt) {
|
||||
Grid.mouseDownOnCursor(evt);
|
||||
};
|
||||
cnv.onmousedown = function (evt) {
|
||||
Grid.mouseDownOnCursor(evt);
|
||||
};
|
||||
var ctx = cnv.getContext('2d');
|
||||
ctx.globalAlpha = 0.5;
|
||||
ctx.fillStyle = '#28A5DA';
|
||||
|
@ -169,11 +163,8 @@ export default class Grid {
|
|||
ctx.lineWidth = 3;
|
||||
ctx.strokeRect(3, 3, size - 6, size - 6);
|
||||
ctx.fillRect(3, 3, size - 6, size - 6);
|
||||
if (isTablet) {
|
||||
gc.ontouchstart = Grid.mouseDownOnCursor;
|
||||
} else {
|
||||
gc.onmousedown = Grid.mouseDownOnCursor;
|
||||
}
|
||||
gc.ontouchstart = Grid.mouseDownOnCursor;
|
||||
gc.onmousedown = Grid.mouseDownOnCursor;
|
||||
}
|
||||
|
||||
static mouseDownOnCursor (e) {
|
||||
|
|
|
@ -144,6 +144,9 @@ export default class Events {
|
|||
}
|
||||
|
||||
static holdit (c, fcn) {
|
||||
if (timeoutEvent) {
|
||||
return;
|
||||
}
|
||||
var repeat = function () {
|
||||
Events.clearEvents();
|
||||
fcn(dragthumbnail);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue