Use direct call to svg resize rather than event. Also fix issue #296.

This commit is contained in:
Neil Fraser
2016-05-04 15:00:57 -07:00
parent 554fe18ab9
commit 217c681b86
9 changed files with 39 additions and 68 deletions

View File

@@ -163,63 +163,6 @@ Blockly.unbindEvent_ = function(bindData) {
return func;
};
/**
* Fire a synthetic event synchronously.
* @param {!EventTarget} node The event's target node.
* @param {string} eventName Name of event (e.g. 'click').
*/
Blockly.fireUiEventNow = function(node, eventName) {
// Remove the event from the anti-duplicate database.
var list = Blockly.fireUiEvent.DB_[eventName];
if (list) {
var i = list.indexOf(node);
if (i != -1) {
list.splice(i, 1);
}
}
// Create a UI event in a browser-compatible way.
if (typeof UIEvent == 'function') {
// W3
var evt = new UIEvent(eventName, {});
} else {
// MSIE
var evt = document.createEvent('UIEvent');
evt.initUIEvent(eventName, false, false, window, 0);
}
node.dispatchEvent(evt);
};
/**
* Fire a synthetic event asynchronously. Groups of simultaneous events (e.g.
* a tree of blocks being deleted) are merged into one event.
* @param {!EventTarget} node The event's target node.
* @param {string} eventName Name of event (e.g. 'click').
*/
Blockly.fireUiEvent = function(node, eventName) {
var list = Blockly.fireUiEvent.DB_[eventName];
if (list) {
if (list.indexOf(node) != -1) {
// This event is already scheduled to fire.
return;
}
list.push(node);
} else {
Blockly.fireUiEvent.DB_[eventName] = [node];
}
var fire = function() {
Blockly.fireUiEventNow(node, eventName);
};
setTimeout(fire, 0);
};
/**
* Database of upcoming firing event types.
* Used to fire only one event after multiple changes.
* @type {!Object}
* @private
*/
Blockly.fireUiEvent.DB_ = {};
/**
* Don't do anything for this event, just halt propagation.
* @param {!Event} e An event.