mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
reset touch identifier at the end of a toolbox click
This commit is contained in:
parent
b3cd33d440
commit
e4fcd8bf5c
2 changed files with 18 additions and 3 deletions
|
@ -156,6 +156,14 @@ Blockly.resizeSvgContents = function(workspace) {
|
|||
workspace.resizeContents();
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear the touch identifier that tracks which touch stream to pay attention
|
||||
* to.
|
||||
*/
|
||||
Blockly.clearTouchIdentifier = function() {
|
||||
Blockly.touchIdentifier_ = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Decide whether Blockly should handle or ignore this event.
|
||||
* Mouse and touch events require special checks because we only want to deal
|
||||
|
@ -181,9 +189,14 @@ Blockly.shouldHandleEvent = function(e) {
|
|||
*/
|
||||
Blockly.checkTouchIdentifier = function(e) {
|
||||
var identifier = (e.changedTouches && e.changedTouches.item(0) &&
|
||||
e.changedTouches.item(0).identifier) || 'mouse';
|
||||
e.changedTouches.item(0).identifier != undefined &&
|
||||
e.changedTouches.item(0).identifier != null) ?
|
||||
e.changedTouches.item(0).identifier : 'mouse';
|
||||
|
||||
if (Blockly.touchIdentifier_) {
|
||||
// if (Blockly.touchIdentifier_ )is insufficient because android touch
|
||||
// identifiers may be zero.
|
||||
if (Blockly.touchIdentifier_ != undefined &&
|
||||
Blockly.touchIdentifier_ != null) {
|
||||
// We're already tracking some touch/mouse event. Is this from the same
|
||||
// source?
|
||||
return Blockly.touchIdentifier_ == identifier;
|
||||
|
|
|
@ -468,12 +468,14 @@ goog.inherits(Blockly.Toolbox.TreeControl, goog.ui.tree.TreeControl);
|
|||
Blockly.Toolbox.TreeControl.prototype.enterDocument = function() {
|
||||
Blockly.Toolbox.TreeControl.superClass_.enterDocument.call(this);
|
||||
|
||||
var el = this.getElement();
|
||||
// Add touch handler.
|
||||
if (goog.events.BrowserFeature.TOUCH_ENABLED) {
|
||||
var el = this.getElement();
|
||||
Blockly.bindEvent_(el, goog.events.EventType.TOUCHSTART, this,
|
||||
this.handleTouchEvent_);
|
||||
}
|
||||
|
||||
Blockly.bindEvent_(el, 'mouseup', this, Blockly.clearTouchIdentifier);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue