Commit 7c5671e5 authored by neil.fraser@gmail.com's avatar neil.fraser@gmail.com

Fix touch bug which dropped blocks when created from an autoclosing flyout.

git-svn-id: http://blockly.googlecode.com/svn/trunk@1743 c400ca83-b69d-9dd7-9705-49c6b8615e23
parent 2ac9c905
This diff is collapsed.
......@@ -302,27 +302,30 @@ Blockly.Flyout.prototype.hide = function() {
Blockly.unbindEvent_(this.reflowWrapper_);
this.reflowWrapper_ = null;
}
// Delete all the blocks.
// Do NOT delete the blocks here. Wait until Flyout.show.
// https://neil.fraser.name/news/2014/08/09/
};
/**
* Show and populate the flyout.
* @param {!Array|string} xmlList List of blocks to show.
* Variables and procedures have a custom set of blocks.
*/
Blockly.Flyout.prototype.show = function(xmlList) {
this.hide();
// Delete any blocks from a previous showing.
var blocks = this.workspace_.getTopBlocks(false);
for (var x = 0, block; block = blocks[x]; x++) {
if (block.workspace == this.workspace_) {
block.dispose(false, false);
}
}
// Delete all the background buttons.
// Delete any background buttons from a previous showing.
for (var x = 0, rect; rect = this.buttons_[x]; x++) {
goog.dom.removeNode(rect);
}
this.buttons_.splice(0);
};
/**
* Show and populate the flyout.
* @param {!Array|string} xmlList List of blocks to show.
* Variables and procedures have a custom set of blocks.
*/
Blockly.Flyout.prototype.show = function(xmlList) {
this.hide();
var margin = this.CORNER_RADIUS;
this.svgGroup_.style.display = 'block';
......
......@@ -100,9 +100,11 @@ Blockly.bindEvent_ = function(node, name, thisObject, func) {
// Stop the browser from scrolling/zooming the page
e.preventDefault();
};
node.addEventListener(Blockly.bindEvent_.TOUCH_MAP[name],
wrapFunc, false);
bindData.push([node, Blockly.bindEvent_.TOUCH_MAP[name], wrapFunc]);
for (var i = 0, eventName;
eventName = Blockly.bindEvent_.TOUCH_MAP[name][i]; i++) {
node.addEventListener(eventName, wrapFunc, false);
bindData.push([node, eventName, wrapFunc]);
}
}
return bindData;
};
......@@ -115,9 +117,9 @@ Blockly.bindEvent_ = function(node, name, thisObject, func) {
Blockly.bindEvent_.TOUCH_MAP = {};
if ('ontouchstart' in document.documentElement) {
Blockly.bindEvent_.TOUCH_MAP = {
'mousedown': 'touchstart',
'mousemove': 'touchmove',
'mouseup': 'touchend'
'mousedown': ['touchstart'],
'mousemove': ['touchmove'],
'mouseup': ['touchend', 'touchcancel']
};
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment