mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Make scrollCenter public, remove zoomReset.
This commit is contained in:
parent
3df4173039
commit
fd7d4a2bef
2 changed files with 10 additions and 18 deletions
|
@ -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;
|
||||
|
|
|
@ -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_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue