Commit dcd463b5 authored by Neil Fraser's avatar Neil Fraser

Add 'startScale' and remove 'enabled' options on zoom.

parent 54ffdc59
......@@ -161,19 +161,17 @@ Blockly.parseOptions_ = function(options) {
/* TODO (fraser): Add documentation page:
* https://developers.google.com/blockly/installation/zoom
*
* enabled
*
* Set to `true` to allow zooming of the main workspace. Zooming is only
* possible if the workspace has scrollbars. If `false`, then the options
* below have no effect. Defaults to `false`.
*
* controls
*
* Set to `true` to show zoom-in and zoom-out buttons. Defaults to `true`.
* Set to `true` to show zoom-in and zoom-out buttons. Defaults to `false`.
*
* wheel
*
* Set to `true` to allow the mouse wheel to zoom. Defaults to `true`.
* Set to `true` to allow the mouse wheel to zoom. Defaults to `false`.
*
* startScale
*
* Initial magnification factor. Defaults to `1.0`.
*
* maxScale
*
......@@ -194,36 +192,35 @@ Blockly.parseOptions_ = function(options) {
// https://developers.google.com/blockly/installation/zoom
var zoom = options['zoom'] || {};
var zoomOptions = {};
zoomOptions.enabled = hasScrollbars && !!zoom['enabled'];
if (zoomOptions.enabled) {
if (zoom['controls'] === undefined) {
zoomOptions.controls = true;
} else {
zoomOptions.controls = !!zoom['controls'];
}
if (zoom['wheel'] === undefined) {
zoomOptions.wheel = true;
} else {
zoomOptions.wheel = !!zoom['wheel'];
}
if (zoom['maxScale'] === undefined) {
zoomOptions.maxScale = 3;
} else {
zoomOptions.maxScale = parseFloat(zoom['maxScale']);
}
if (zoom['minScale'] === undefined) {
zoomOptions.minScale = 0.3;
} else {
zoomOptions.minScale = parseFloat(zoom['minScale']);
}
if (zoom['scaleSpeed'] === undefined) {
zoomOptions.scaleSpeed = 1.2;
} else {
zoomOptions.scaleSpeed = parseFloat(zoom['scaleSpeed']);
}
} else {
if (zoom['controls'] === undefined) {
zoomOptions.controls = false;
} else {
zoomOptions.controls = !!zoom['controls'];
}
if (zoom['wheel'] === undefined) {
zoomOptions.wheel = false;
} else {
zoomOptions.wheel = !!zoom['wheel'];
}
if (zoom['startScale'] === undefined) {
zoomOptions.startScale = 1;
} else {
zoomOptions.startScale = parseFloat(zoom['startScale']);
}
if (zoom['maxScale'] === undefined) {
zoomOptions.maxScale = 3;
} else {
zoomOptions.maxScale = parseFloat(zoom['maxScale']);
}
if (zoom['minScale'] === undefined) {
zoomOptions.minScale = 0.3;
} else {
zoomOptions.minScale = parseFloat(zoom['minScale']);
}
if (zoom['scaleSpeed'] === undefined) {
zoomOptions.scaleSpeed = 1.2;
} else {
zoomOptions.scaleSpeed = parseFloat(zoom['scaleSpeed']);
}
var enableRealtime = !!options['realtime'];
......@@ -377,6 +374,7 @@ Blockly.createMainWorkspace_ = function(svg, options) {
options.getMetrics = Blockly.getMainWorkspaceMetrics_;
options.setMetrics = Blockly.setMainWorkspaceMetrics_;
var mainWorkspace = new Blockly.WorkspaceSvg(options);
mainWorkspace.scale = options.zoomOptions.startScale;
svg.appendChild(mainWorkspace.createDom('blocklyMainBackground'));
mainWorkspace.markFocused();
......
......@@ -384,7 +384,9 @@ Code.init = function() {
media: '../../media/',
rtl: rtl,
toolbox: toolbox,
zoom: {enabled: true}
zoom:
{controls: true,
wheel: true}
});
// Add to reserved word list: Local variables in execution environment (runJS)
......
......@@ -84,9 +84,9 @@ function start() {
scrollbars: true,
toolbox: toolbox,
zoom:
{enabled: true,
controls: true,
{controls: true,
wheel: true,
startScale: 2.0,
maxScale: 4,
minScale: .25,
scaleSpeed: 1.1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment