mirror of
https://github.com/google/blockly.git
synced 2026-01-09 10:00:09 +01:00
Merge pull request #1737 from rachel-fenichel/feature/enable_pinch_to_zoom
Enable touch gestures and pinch-to-zoom
This commit is contained in:
@@ -36,6 +36,7 @@ goog.require('Blockly.Grid');
|
||||
goog.require('Blockly.Options');
|
||||
goog.require('Blockly.ScrollbarPair');
|
||||
goog.require('Blockly.Touch');
|
||||
goog.require('Blockly.TouchGesture');
|
||||
goog.require('Blockly.Trashcan');
|
||||
goog.require('Blockly.VariablesDynamic');
|
||||
goog.require('Blockly.Workspace');
|
||||
@@ -206,7 +207,7 @@ Blockly.WorkspaceSvg.prototype.scrollbar = null;
|
||||
|
||||
/**
|
||||
* The current gesture in progress on this workspace, if any.
|
||||
* @type {Blockly.Gesture}
|
||||
* @type {Blockly.TouchGesture}
|
||||
* @private
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.currentGesture_ = null;
|
||||
@@ -1847,12 +1848,13 @@ Blockly.WorkspaceSvg.prototype.removeToolboxCategoryCallback = function(key) {
|
||||
* Look up the gesture that is tracking this touch stream on this workspace.
|
||||
* May create a new gesture.
|
||||
* @param {!Event} e Mouse event or touch event.
|
||||
* @return {Blockly.Gesture} The gesture that is tracking this touch stream,
|
||||
* or null if no valid gesture exists.
|
||||
* @return {Blockly.TouchGesture} The gesture that is tracking this touch
|
||||
* stream, or null if no valid gesture exists.
|
||||
* @package
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.getGesture = function(e) {
|
||||
var isStart = (e.type == 'mousedown' || e.type == 'touchstart' || e.type == 'pointerdown');
|
||||
var isStart = (e.type == 'mousedown' || e.type == 'touchstart' ||
|
||||
e.type == 'pointerdown');
|
||||
|
||||
var gesture = this.currentGesture_;
|
||||
if (gesture) {
|
||||
@@ -1869,7 +1871,7 @@ Blockly.WorkspaceSvg.prototype.getGesture = function(e) {
|
||||
// No gesture existed on this workspace, but this looks like the start of a
|
||||
// new gesture.
|
||||
if (isStart) {
|
||||
this.currentGesture_ = new Blockly.Gesture(e, this);
|
||||
this.currentGesture_ = new Blockly.TouchGesture(e, this);
|
||||
return this.currentGesture_;
|
||||
}
|
||||
// No gesture existed and this event couldn't be the start of a new gesture.
|
||||
|
||||
Reference in New Issue
Block a user