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
Hide 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) {
...
@@ -161,19 +161,17 @@ Blockly.parseOptions_ = function(options) {
/* TODO (fraser): Add documentation page:
/* TODO (fraser): Add documentation page:
* https://developers.google.com/blockly/installation/zoom
* 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
* 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
* 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
* maxScale
*
*
...
@@ -194,36 +192,35 @@ Blockly.parseOptions_ = function(options) {
...
@@ -194,36 +192,35 @@ Blockly.parseOptions_ = function(options) {
// https://developers.google.com/blockly/installation/zoom
// https://developers.google.com/blockly/installation/zoom
var
zoom
=
options
[
'
zoom
'
]
||
{};
var
zoom
=
options
[
'
zoom
'
]
||
{};
var
zoomOptions
=
{};
var
zoomOptions
=
{};
zoomOptions
.
enabled
=
hasScrollbars
&&
!!
zoom
[
'
enabled
'
];
if
(
zoom
[
'
controls
'
]
===
undefined
)
{
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
{
zoomOptions
.
controls
=
false
;
zoomOptions
.
controls
=
false
;
}
else
{
zoomOptions
.
controls
=
!!
zoom
[
'
controls
'
];
}
if
(
zoom
[
'
wheel
'
]
===
undefined
)
{
zoomOptions
.
wheel
=
false
;
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
'
];
var
enableRealtime
=
!!
options
[
'
realtime
'
];
...
@@ -377,6 +374,7 @@ Blockly.createMainWorkspace_ = function(svg, options) {
...
@@ -377,6 +374,7 @@ Blockly.createMainWorkspace_ = function(svg, options) {
options
.
getMetrics
=
Blockly
.
getMainWorkspaceMetrics_
;
options
.
getMetrics
=
Blockly
.
getMainWorkspaceMetrics_
;
options
.
setMetrics
=
Blockly
.
setMainWorkspaceMetrics_
;
options
.
setMetrics
=
Blockly
.
setMainWorkspaceMetrics_
;
var
mainWorkspace
=
new
Blockly
.
WorkspaceSvg
(
options
);
var
mainWorkspace
=
new
Blockly
.
WorkspaceSvg
(
options
);
mainWorkspace
.
scale
=
options
.
zoomOptions
.
startScale
;
svg
.
appendChild
(
mainWorkspace
.
createDom
(
'
blocklyMainBackground
'
));
svg
.
appendChild
(
mainWorkspace
.
createDom
(
'
blocklyMainBackground
'
));
mainWorkspace
.
markFocused
();
mainWorkspace
.
markFocused
();
...
...
demos/code/code.js
View file @
dcd463b5
...
@@ -384,7 +384,9 @@ Code.init = function() {
...
@@ -384,7 +384,9 @@ Code.init = function() {
media
:
'
../../media/
'
,
media
:
'
../../media/
'
,
rtl
:
rtl
,
rtl
:
rtl
,
toolbox
:
toolbox
,
toolbox
:
toolbox
,
zoom
:
{
enabled
:
true
}
zoom
:
{
controls
:
true
,
wheel
:
true
}
});
});
// Add to reserved word list: Local variables in execution environment (runJS)
// Add to reserved word list: Local variables in execution environment (runJS)
...
...
tests/playground.html
View file @
dcd463b5
...
@@ -84,9 +84,9 @@ function start() {
...
@@ -84,9 +84,9 @@ function start() {
scrollbars
:
true
,
scrollbars
:
true
,
toolbox
:
toolbox
,
toolbox
:
toolbox
,
zoom
:
zoom
:
{
enabled
:
true
,
{
controls
:
true
,
controls
:
true
,
wheel
:
true
,
wheel
:
true
,
startScale
:
2.0
,
maxScale
:
4
,
maxScale
:
4
,
minScale
:
.
25
,
minScale
:
.
25
,
scaleSpeed
:
1.1
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