mirror of
https://github.com/google/blockly.git
synced 2025-12-16 06:10:12 +01:00
Fix code in code demo executing twice on mobile (#5037)
* Prevent code from executing twice on touchscreens
This commit is contained in:
@@ -549,8 +549,14 @@ Code.initLanguage = function() {
|
|||||||
/**
|
/**
|
||||||
* Execute the user's code.
|
* Execute the user's code.
|
||||||
* Just a quick and dirty eval. Catch infinite loops.
|
* Just a quick and dirty eval. Catch infinite loops.
|
||||||
|
* @param {Event} event Event created from listener bound to the function.
|
||||||
*/
|
*/
|
||||||
Code.runJS = function() {
|
Code.runJS = function(event) {
|
||||||
|
// Prevent code from being executed twice on touchscreens.
|
||||||
|
if (event.type == 'touchend') {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
Blockly.JavaScript.INFINITE_LOOP_TRAP = 'checkTimeout();\n';
|
Blockly.JavaScript.INFINITE_LOOP_TRAP = 'checkTimeout();\n';
|
||||||
var timeouts = 0;
|
var timeouts = 0;
|
||||||
var checkTimeout = function() {
|
var checkTimeout = function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user