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
a485e63d
Commit
a485e63d
authored
Oct 21, 2015
by
Neil Fraser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow zooming of non-scrolling workspaces.
parent
dcd463b5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
5 deletions
+18
-5
core/flyout.js
core/flyout.js
+3
-0
core/inject.js
core/inject.js
+2
-0
core/workspace_svg.js
core/workspace_svg.js
+12
-4
tests/playground.html
tests/playground.html
+1
-1
No files found.
core/flyout.js
View file @
a485e63d
...
@@ -652,6 +652,9 @@ Blockly.Flyout.prototype.createBlockFunc_ = function(originBlock) {
...
@@ -652,6 +652,9 @@ Blockly.Flyout.prototype.createBlockFunc_ = function(originBlock) {
// Scale the scroll (getSvgXY_ did not do this).
// Scale the scroll (getSvgXY_ did not do this).
xyNew
.
x
+=
workspace
.
scrollX
/
workspace
.
scale
-
workspace
.
scrollX
;
xyNew
.
x
+=
workspace
.
scrollX
/
workspace
.
scale
-
workspace
.
scrollX
;
xyNew
.
y
+=
workspace
.
scrollY
/
workspace
.
scale
-
workspace
.
scrollY
;
xyNew
.
y
+=
workspace
.
scrollY
/
workspace
.
scale
-
workspace
.
scrollY
;
if
(
workspace
.
toolbox_
&&
!
workspace
.
scrollbar
)
{
xyNew
.
x
+=
workspace
.
toolbox_
.
width
/
workspace
.
scale
;
}
block
.
moveBy
(
xyOld
.
x
-
xyNew
.
x
,
xyOld
.
y
-
xyNew
.
y
);
block
.
moveBy
(
xyOld
.
x
-
xyNew
.
x
,
xyOld
.
y
-
xyNew
.
y
);
if
(
flyout
.
autoClose
)
{
if
(
flyout
.
autoClose
)
{
flyout
.
hide
();
flyout
.
hide
();
...
...
core/inject.js
View file @
a485e63d
...
@@ -376,6 +376,8 @@ Blockly.createMainWorkspace_ = function(svg, options) {
...
@@ -376,6 +376,8 @@ Blockly.createMainWorkspace_ = function(svg, options) {
var
mainWorkspace
=
new
Blockly
.
WorkspaceSvg
(
options
);
var
mainWorkspace
=
new
Blockly
.
WorkspaceSvg
(
options
);
mainWorkspace
.
scale
=
options
.
zoomOptions
.
startScale
;
mainWorkspace
.
scale
=
options
.
zoomOptions
.
startScale
;
svg
.
appendChild
(
mainWorkspace
.
createDom
(
'
blocklyMainBackground
'
));
svg
.
appendChild
(
mainWorkspace
.
createDom
(
'
blocklyMainBackground
'
));
// A null translation will also apply the correct initial scale.
mainWorkspace
.
translate
(
0
,
0
);
mainWorkspace
.
markFocused
();
mainWorkspace
.
markFocused
();
if
(
!
options
.
readOnly
&&
!
options
.
hasScrollbars
)
{
if
(
!
options
.
readOnly
&&
!
options
.
hasScrollbars
)
{
...
...
core/workspace_svg.js
View file @
a485e63d
...
@@ -317,7 +317,7 @@ Blockly.WorkspaceSvg.prototype.getBubbleCanvas = function() {
...
@@ -317,7 +317,7 @@ Blockly.WorkspaceSvg.prototype.getBubbleCanvas = function() {
* @param {number} y Vertical translation.
* @param {number} y Vertical translation.
*/
*/
Blockly
.
WorkspaceSvg
.
prototype
.
translate
=
function
(
x
,
y
)
{
Blockly
.
WorkspaceSvg
.
prototype
.
translate
=
function
(
x
,
y
)
{
var
translation
=
'
translate(
'
+
x
+
'
,
'
+
y
+
'
)
'
+
var
translation
=
'
translate(
'
+
x
+
'
,
'
+
y
+
'
)
'
+
'
scale(
'
+
this
.
scale
+
'
)
'
;
'
scale(
'
+
this
.
scale
+
'
)
'
;
this
.
svgBlockCanvas_
.
setAttribute
(
'
transform
'
,
translation
);
this
.
svgBlockCanvas_
.
setAttribute
(
'
transform
'
,
translation
);
this
.
svgBubbleCanvas_
.
setAttribute
(
'
transform
'
,
translation
);
this
.
svgBubbleCanvas_
.
setAttribute
(
'
transform
'
,
translation
);
...
@@ -922,7 +922,11 @@ Blockly.WorkspaceSvg.prototype.zoom = function(x, y, type) {
...
@@ -922,7 +922,11 @@ Blockly.WorkspaceSvg.prototype.zoom = function(x, y, type) {
this
.
scrollX
=
matrix
.
e
-
metrics
.
absoluteLeft
;
this
.
scrollX
=
matrix
.
e
-
metrics
.
absoluteLeft
;
this
.
scrollY
=
matrix
.
f
-
metrics
.
absoluteTop
;
this
.
scrollY
=
matrix
.
f
-
metrics
.
absoluteTop
;
this
.
updateGridPattern_
();
this
.
updateGridPattern_
();
this
.
scrollbar
.
resize
();
if
(
this
.
scrollbar
)
{
this
.
scrollbar
.
resize
();
}
else
{
this
.
translate
(
0
,
0
);
}
Blockly
.
hideChaff
(
false
);
Blockly
.
hideChaff
(
false
);
if
(
this
.
flyout_
)
{
if
(
this
.
flyout_
)
{
// No toolbox, resize flyout.
// No toolbox, resize flyout.
...
@@ -959,8 +963,12 @@ Blockly.WorkspaceSvg.prototype.zoomReset = function(e) {
...
@@ -959,8 +963,12 @@ Blockly.WorkspaceSvg.prototype.zoomReset = function(e) {
}
}
// Center the workspace.
// Center the workspace.
var
metrics
=
this
.
getMetrics
();
var
metrics
=
this
.
getMetrics
();
this
.
scrollbar
.
set
((
metrics
.
contentWidth
-
metrics
.
viewWidth
)
/
2
,
if
(
this
.
scrollbar
)
{
(
metrics
.
contentHeight
-
metrics
.
viewHeight
)
/
2
);
this
.
scrollbar
.
set
((
metrics
.
contentWidth
-
metrics
.
viewWidth
)
/
2
,
(
metrics
.
contentHeight
-
metrics
.
viewHeight
)
/
2
);
}
else
{
this
.
translate
(
0
,
0
);
}
// This event has been handled. Don't start a workspace drag.
// This event has been handled. Don't start a workspace drag.
e
.
stopPropagation
();
e
.
stopPropagation
();
};
};
...
...
tests/playground.html
View file @
a485e63d
...
@@ -86,7 +86,7 @@ function start() {
...
@@ -86,7 +86,7 @@ function start() {
zoom
:
zoom
:
{
controls
:
true
,
{
controls
:
true
,
wheel
:
true
,
wheel
:
true
,
startScale
:
2
.0
,
startScale
:
1
.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