mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Remove "fake some drags!" button from playground
Removed the "fakeManyDrags", "fakeDrag", "fakeDragWrapper" functions; removed button input that called "fakeManyDrags"
This commit is contained in:
parent
bc1550e1b1
commit
3ce4930c65
1 changed files with 0 additions and 61 deletions
|
@ -27,7 +27,6 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
var fakeDragStack = [];
|
||||
var workspace = null;
|
||||
|
||||
function start() {
|
||||
|
@ -290,65 +289,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
function fakeDrag(id, dx, dy, opt_workspace) {
|
||||
var ws = opt_workspace || Blockly.getMainWorkspace();
|
||||
var blockToDrag = ws.getBlockById(id);
|
||||
|
||||
if (!blockToDrag) {
|
||||
fakeDragWrapper();
|
||||
return;
|
||||
}
|
||||
var blockTop = blockToDrag.svgGroup_.getBoundingClientRect().top;
|
||||
var blockLeft = blockToDrag.svgGroup_.getBoundingClientRect().left;
|
||||
|
||||
// Click somewhere on the block.
|
||||
var mouseDownEvent = new MouseEvent('mousedown',
|
||||
{clientX: blockLeft + 5, clientY: blockTop + 5});
|
||||
blockToDrag.onMouseDown_(mouseDownEvent);
|
||||
|
||||
// Throw in a move for good measure.
|
||||
setTimeout(
|
||||
function() {
|
||||
var mouseMoveEvent = new MouseEvent('mousemove',
|
||||
{clientX: blockLeft + dx,
|
||||
clientY: blockTop + dy});
|
||||
blockToDrag.onMouseMove_(mouseMoveEvent);
|
||||
|
||||
// Drop at dx, dy.
|
||||
setTimeout(
|
||||
function() {
|
||||
var mouseUpEvent = new MouseEvent('mouseup',
|
||||
{clientX: blockLeft + dx,
|
||||
clientY: blockTop + dy});
|
||||
blockToDrag.onMouseUp_(mouseUpEvent);
|
||||
|
||||
setTimeout(fakeDragWrapper(), 100);
|
||||
}, 30);
|
||||
}, 30);
|
||||
};
|
||||
|
||||
function fakeDragWrapper() {
|
||||
var dragInfo = fakeDragStack.pop();
|
||||
if (dragInfo) {
|
||||
fakeDrag(dragInfo.id, dragInfo.dx, dragInfo.dy, dragInfo.workspace);
|
||||
}
|
||||
}
|
||||
|
||||
function fakeManyDrags() {
|
||||
var blockList = workspace.getAllBlocks();
|
||||
for (var i = 0; i < 2 * blockList.length; i++) {
|
||||
fakeDragStack.push(
|
||||
{
|
||||
id: blockList[Math.round(Math.random() * (blockList.length - 1))].id,
|
||||
// Move some blocks up and to the left, but mostly down and to the right.
|
||||
dx: Math.round((Math.random() - 0.25) * 200),
|
||||
dy: Math.round((Math.random() - 0.25) * 200),
|
||||
workspace: workspace
|
||||
});
|
||||
}
|
||||
fakeDragWrapper();
|
||||
}
|
||||
|
||||
function reportDemo() {
|
||||
if (Blockly.selected) {
|
||||
workspace.reportValue(
|
||||
|
@ -565,7 +505,6 @@
|
|||
Stress test:
|
||||
<input type="button" value="Sprinkles!" onclick="sprinkles(100)">
|
||||
<input type="button" value="Spaghetti!" onclick="spaghetti(3)">
|
||||
<input type="button" value="Fake some drags!" onclick="fakeManyDrags()">
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue