diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 4b9570ce3..2d562fd2e 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -1038,26 +1038,13 @@ Blockly.WorkspaceSvg.prototype.zoomToFit = function() { var ratioX = workspaceWidth / blocksWidth; var ratioY = workspaceHeight / blocksHeight; this.setScale(Math.min(ratioX, ratioY)); - this.scrollCenter_(); -}; - -/** - * Reset zooming and dragging. - * @param {!Event} e Mouse down event. - */ -Blockly.WorkspaceSvg.prototype.zoomReset = function(e) { - this.setScale(1); - this.scrollCenter_(); - // This event has been handled. Don't start a workspace drag. - e.stopPropagation(); - e.preventDefault(); + this.scrollCenter(); }; /** * Center the workspace. - * @private */ -Blockly.WorkspaceSvg.prototype.scrollCenter_ = function() { +Blockly.WorkspaceSvg.prototype.scrollCenter = function() { if (!this.scrollbar) { // Can't center a non-scrolling workspace. return; diff --git a/core/zoom_controls.js b/core/zoom_controls.js index f745c9c21..d50110829 100644 --- a/core/zoom_controls.js +++ b/core/zoom_controls.js @@ -162,16 +162,21 @@ Blockly.ZoomControls.prototype.createDom = function() { workspace.options.pathToMedia + Blockly.SPRITE.url); // Attach event listeners. - Blockly.bindEvent_(zoomresetSvg, 'mousedown', workspace, workspace.zoomReset); + Blockly.bindEvent_(zoomresetSvg, 'mousedown', null, function(e) { + workspace.setScale(1); + workspace.scrollCenter(); + e.stopPropagation(); // Don't start a workspace scroll. + e.preventDefault(); // Stop double-clicking from selecting text. + }); Blockly.bindEvent_(zoominSvg, 'mousedown', null, function(e) { workspace.zoomCenter(1); e.stopPropagation(); // Don't start a workspace scroll. - e.preventDefault(); + e.preventDefault(); // Stop double-clicking from selecting text. }); Blockly.bindEvent_(zoomoutSvg, 'mousedown', null, function(e) { workspace.zoomCenter(-1); e.stopPropagation(); // Don't start a workspace scroll. - e.preventDefault(); + e.preventDefault(); // Stop double-clicking from selecting text. }); return this.svgGroup_;