Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.

rename isTablet to supportTouch #481

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/editor/blocks/BlockArg.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import BlockSpecs from './BlockSpecs';
import Menu from './Menu';
import Undo from '../ui/Undo';
import {setCanvasSize, setProps, writeText, scaleMultiplier,
newHTML, newDiv, newCanvas, getStringSize, isTablet,
newHTML, newDiv, newCanvas, getStringSize,
newP, globalx, globaly} from '../../utils/lib';
import Localization from '../../utils/Localization';

Expand Down Expand Up @@ -295,7 +295,7 @@ export default class BlockArg {
}

pressDropDown (e, fcn) {
if (isTablet && e.touches && (e.touches.length > 1)) {
if (e.touches && (e.touches.length > 1)) {
return;
}
if (ScratchJr.onHold) {
Expand Down
4 changes: 2 additions & 2 deletions src/editor/blocks/Menu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BlockSpecs from './BlockSpecs';
import {scaleMultiplier, setProps, setCanvasSize, newHTML, isTablet,
import {scaleMultiplier, setProps, setCanvasSize, newHTML,
newDiv, getDocumentHeight, drawThumbnail, frame, globalx, globaly} from '../../utils/lib';

let openMenu = undefined;
Expand Down Expand Up @@ -82,7 +82,7 @@ export default class Menu {
fcn(evt, mu, block, c);
};
function handleTouchStart (e) {
if (isTablet && e.touches && (e.touches.length > 1)) {
if (e.touches && (e.touches.length > 1)) {
return;
}
e.preventDefault();
Expand Down
10 changes: 3 additions & 7 deletions src/editor/engine/Sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import ScratchAudio from '../../utils/ScratchAudio';
import Scripts from '../ui/Scripts';
import {newHTML, newDiv, newP, gn,
setCanvasSizeScaledToWindowDocumentHeight,
DEGTOR, getIdFor, setProps, isTablet, isiOS,
DEGTOR, getIdFor, setProps, isiOS,
isAndroid, fitInRect, scaleMultiplier, setCanvasSize,
globaly, globalx, rgbToHex} from '../../utils/lib';

Expand Down Expand Up @@ -911,13 +911,9 @@ export default class Sprite {
me.unfocusText();
});
} else {
if (isTablet) {
setTimeout(function () {
ti.focus();
} else {
setTimeout(function () {
ti.focus();
}, 100);
}
}, 100);
}
}

Expand Down
39 changes: 15 additions & 24 deletions src/editor/ui/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -153,27 +150,21 @@ 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';
ctx.strokeStyle = '#656e73';
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) {
Expand Down
4 changes: 2 additions & 2 deletions src/editor/ui/Palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Rectangle from '../../geom/Rectangle';
import DrawPath from '../../utils/DrawPath';
import ScratchAudio from '../../utils/ScratchAudio';
import Record from './Record';
import {frame, gn, localx, newHTML, scaleMultiplier, isTablet, newDiv,
import {frame, gn, localx, newHTML, scaleMultiplier, newDiv,
setProps, globalx, localy, globaly, drawScaled, newCanvas,
setCanvasSize, hitRect, writeText, getStringSize} from '../../utils/lib';

Expand Down Expand Up @@ -71,7 +71,7 @@ export default class Palette {
}

static paletteMouseDown (e) {
if (isTablet && e.touches && (e.touches.length > 1)) {
if (e.touches && (e.touches.length > 1)) {
return;
}
if (ScratchJr.onHold) {
Expand Down
4 changes: 2 additions & 2 deletions src/editor/ui/Scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ScriptsPane from './ScriptsPane';
import Events from '../../utils/Events';
import ScratchAudio from '../../utils/ScratchAudio';
import {gn, newHTML, setCanvasSize, setProps,
localx, localy, scaleMultiplier, hit3DRect, isTablet} from '../../utils/lib';
localx, localy, scaleMultiplier, hit3DRect} from '../../utils/lib';

export default class Scripts {
constructor (spr) {
Expand Down Expand Up @@ -43,7 +43,7 @@ export default class Scripts {
////////////////////////////////////////////////

scriptsMouseDown (e) {
if (isTablet && e.touches && (e.touches.length > 1)) {
if (e.touches && (e.touches.length > 1)) {
return;
}
if (ScratchJr.onHold) {
Expand Down
31 changes: 14 additions & 17 deletions src/editor/ui/ScriptsPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Events from '../../utils/Events';
import Scroll from './Scroll';
import Menu from '../blocks/Menu';
import ScratchAudio from '../../utils/ScratchAudio';
import {gn, localx, localy, newHTML, isTablet,
import {gn, localx, localy, newHTML,
globalx, globaly, setCanvasSize, getDocumentHeight, frame} from '../../utils/lib';

let scroll = undefined;
Expand Down Expand Up @@ -254,7 +254,7 @@ export default class ScriptsPane {
if (Menu.openMenu) {
return;
}
if (isTablet && e.touches && (e.touches.length > 1)) {
if (e.touches && (e.touches.length > 1)) {
return;
}
e.preventDefault();
Expand All @@ -270,21 +270,18 @@ export default class ScriptsPane {
}

static setDragBackgroundEvents (fcnmove, fcnup) {
if (isTablet) { // setDragBackgroundEvents
window.ontouchmove = function (evt) {
fcnmove(evt);
};
window.ontouchend = function (evt) {
fcnup(evt);
};
} else {
window.onmousemove = function (evt) {
fcnmove(evt);
};
window.onmouseup = function (evt) {
fcnup(evt);
};
}
window.ontouchmove = function (evt) {
fcnmove(evt);
};
window.ontouchend = function (evt) {
fcnup(evt);
};
window.onmousemove = function (evt) {
fcnmove(evt);
};
window.onmouseup = function (evt) {
fcnup(evt);
};
}

static dragMove (e) {
Expand Down
70 changes: 29 additions & 41 deletions src/editor/ui/Scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
////////////////////////////////////////////////

import Events from '../../utils/Events';
import {newDiv, newHTML, CSSTransition3D, isTablet, setCanvasSize} from '../../utils/lib';
import {newDiv, newHTML, CSSTransition3D, setCanvasSize} from '../../utils/lib';

export default class Scroll {
constructor (div, id, w, h, cfcn, ofcn) {
Expand Down Expand Up @@ -50,45 +50,33 @@ export default class Scroll {
newHTML('div', 'halign down', this.adown);

var me = this;
if (isTablet) {
this.aup.ontouchstart = function (e) {
me.scrolldown(e);
};
} else {
this.aup.onmousedown = function (e) {
me.scrolldown(e);
};
}
this.aup.ontouchstart = function (e) {
me.scrolldown(e);
};
this.aup.onmousedown = function (e) {
me.scrolldown(e);
};

if (isTablet) {
this.adown.ontouchstart = function (e) {
me.scrollup(e);
};
} else {
this.adown.onmousedown = function (e) {
me.scrollup(e);
};
}
this.adown.ontouchstart = function (e) {
me.scrollup(e);
};
this.adown.onmousedown = function (e) {
me.scrollup(e);
};

if (isTablet) {
this.aleft.ontouchstart = function (e) {
me.scrollright(e);
};
} else {
this.aleft.onmousedown = function (e) {
me.scrollright(e);
};
}
this.aleft.ontouchstart = function (e) {
me.scrollright(e);
};
this.aleft.onmousedown = function (e) {
me.scrollright(e);
};

if (isTablet) {
this.aright.ontouchstart = function (e) {
me.scrollleft(e);
};
} else {
this.aright.onmousedown = function (e) {
me.scrollleft(e);
};
}
this.aright.ontouchstart = function (e) {
me.scrollleft(e);
};
this.aright.onmousedown = function (e) {
me.scrollleft(e);
};

}

Expand Down Expand Up @@ -329,7 +317,7 @@ export default class Scroll {
////////////////////////////////////////////////////////////

scrolldown (e) {
if (isTablet && e.touches && (e.touches.length > 1)) {
if (e.touches && (e.touches.length > 1)) {
return;
}
e.preventDefault();
Expand Down Expand Up @@ -357,7 +345,7 @@ export default class Scroll {
}

scrollup (e) {
if (isTablet && e.touches && (e.touches.length > 1)) {
if (e.touches && (e.touches.length > 1)) {
return;
}
e.preventDefault();
Expand Down Expand Up @@ -385,7 +373,7 @@ export default class Scroll {
}

scrollright (e) {
if (isTablet && e.touches && (e.touches.length > 1)) {
if (e.touches && (e.touches.length > 1)) {
return;
}
e.preventDefault();
Expand Down Expand Up @@ -413,7 +401,7 @@ export default class Scroll {
}

scrollleft (e) {
if (isTablet && e.touches && (e.touches.length > 1)) {
if (e.touches && (e.touches.length > 1)) {
return;
}
e.preventDefault();
Expand Down
4 changes: 2 additions & 2 deletions src/editor/ui/Thumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import OS from '../../tablet/OS';
import Events from '../../utils/Events';
import ScratchAudio from '../../utils/ScratchAudio';
import {frame, gn, localx, newHTML, scaleMultiplier, getIdFor,
isTablet, newImage, localy, setProps} from '../../utils/lib';
newImage, localy, setProps} from '../../utils/lib';

let caret = undefined;

Expand Down Expand Up @@ -360,7 +360,7 @@ export default class Thumbs {
}

static clickOnEmptyPage (e) {
if (isTablet && e.touches && (e.touches.length > 1)) {
if (e.touches && (e.touches.length > 1)) {
return;
}
ScratchAudio.sndFX('tap.wav');
Expand Down
4 changes: 2 additions & 2 deletions src/editor/ui/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Events from '../../utils/Events';
import Localization from '../../utils/Localization';
import ScratchAudio from '../../utils/ScratchAudio';
import {frame, gn, CSSTransition, localx, newHTML, scaleMultiplier, fullscreenScaleMultiplier,
getIdFor, isTablet, newDiv, newTextInput, isAndroid, getDocumentWidth, getDocumentHeight,
getIdFor, newDiv, newTextInput, isAndroid, getDocumentWidth, getDocumentHeight,
setProps, globalx} from '../../utils/lib';

let projectNameTextInput = null;
Expand Down Expand Up @@ -598,7 +598,7 @@ export default class UI {
//////////////////////////////////

static spriteThumbsActions (e) {
if (isTablet && e.touches && (e.touches.length > 1)) {
if (e.touches && (e.touches.length > 1)) {
return;
}
if (ScratchJr.onHold) {
Expand Down
6 changes: 3 additions & 3 deletions src/editor/ui/Undo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Project from './Project';
import Palette from './Palette';
import UI from './UI';
import ScratchAudio from '../../utils/ScratchAudio';
import {newHTML, isTablet, gn} from '../../utils/lib';
import {newHTML, gn} from '../../utils/lib';

let buffer = [];
let index = 0;
Expand Down Expand Up @@ -72,7 +72,7 @@ export default class Undo {
////////////////////////////////

static prevStep (e) {
if (isTablet && e.touches && (e.touches.length > 1)) {
if (e.touches && (e.touches.length > 1)) {
return;
}
e.preventDefault();
Expand All @@ -93,7 +93,7 @@ export default class Undo {
}

static nextStep (e) {
if (isTablet && e.touches && (e.touches.length > 1)) {
if (e.touches && (e.touches.length > 1)) {
return;
}
e.preventDefault();
Expand Down
Loading