Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
dcd463b5
Commit
dcd463b5
authored
Oct 21, 2015
by
Neil Fraser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add 'startScale' and remove 'enabled' options on zoom.
parent
54ffdc59
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
39 deletions
+39
-39
core/inject.js
core/inject.js
+34
-36
demos/code/code.js
demos/code/code.js
+3
-1
tests/playground.html
tests/playground.html
+2
-2
No files found.
core/inject.js
View file @
dcd463b5
...
...
@@ -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 `
tru
e`.
* Set to `true` to show zoom-in and zoom-out buttons. Defaults to `
fals
e`.
*
* 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,18 +192,21 @@ 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
=
tru
e
;
zoomOptions
.
controls
=
fals
e
;
}
else
{
zoomOptions
.
controls
=
!!
zoom
[
'
controls
'
];
}
if
(
zoom
[
'
wheel
'
]
===
undefined
)
{
zoomOptions
.
wheel
=
tru
e
;
zoomOptions
.
wheel
=
fals
e
;
}
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
{
...
...
@@ -221,10 +222,6 @@ Blockly.parseOptions_ = function(options) {
}
else
{
zoomOptions
.
scaleSpeed
=
parseFloat
(
zoom
[
'
scaleSpeed
'
]);
}
}
else
{
zoomOptions
.
controls
=
false
;
zoomOptions
.
wheel
=
false
;
}
var
enableRealtime
=
!!
options
[
'
realtime
'
];
var
realtimeOptions
=
enableRealtime
?
options
[
'
realtimeOptions
'
]
:
undefined
;
...
...
@@ -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
();
...
...
demos/code/code.js
View file @
dcd463b5
...
...
@@ -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)
...
...
tests/playground.html
View file @
dcd463b5
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment