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
f81a5bd1
Commit
f81a5bd1
authored
Aug 26, 2015
by
Neil Fraser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expand regex to handle IE's scientific notation.
parent
ffe49a70
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
core/utils.js
core/utils.js
+13
-6
No files found.
core/utils.js
View file @
f81a5bd1
...
@@ -266,12 +266,7 @@ Blockly.getRelativeXY_ = function(element) {
...
@@ -266,12 +266,7 @@ Blockly.getRelativeXY_ = function(element) {
}
}
// Second, check for transform="translate(...)" attribute.
// Second, check for transform="translate(...)" attribute.
var
transform
=
element
.
getAttribute
(
'
transform
'
);
var
transform
=
element
.
getAttribute
(
'
transform
'
);
// Note that Firefox and IE (9,10) return 'translate(12)' instead of
var
r
=
transform
&&
transform
.
match
(
Blockly
.
getRelativeXY_
.
XY_REGEXP_
);
// 'translate(12, 0)'.
// Note that IE (9,10) returns 'translate(16 8)' instead of
// 'translate(16, 8)'.
var
r
=
transform
&&
transform
.
match
(
/translate
\(\s
*
([
-
\d
.
]
+
)([
,
]\s
*
([
-
\d
.
]
+
)\s
*
\))?
/
);
if
(
r
)
{
if
(
r
)
{
xy
.
x
+=
parseFloat
(
r
[
1
]);
xy
.
x
+=
parseFloat
(
r
[
1
]);
if
(
r
[
3
])
{
if
(
r
[
3
])
{
...
@@ -281,6 +276,18 @@ Blockly.getRelativeXY_ = function(element) {
...
@@ -281,6 +276,18 @@ Blockly.getRelativeXY_ = function(element) {
return
xy
;
return
xy
;
};
};
/**
* Static regex to pull the x,y values out of an SVG translate() directive.
* Note that Firefox and IE (9,10) return 'translate(12)' instead of
* 'translate(12, 0)'.
* Note that IE (9,10) returns 'translate(16 8)' instead of 'translate(16, 8)'.
* Note that IE has been reported to return scientific notation (0.123456e-42).
* @type {!RegExp}
* @private
*/
Blockly
.
getRelativeXY_
.
XY_REGEXP_
=
/translate
\(\s
*
([
-+
\d
.e
]
+
)([
,
]\s
*
([
-+
\d
.e
]
+
)\s
*
\))?
/
;
/**
/**
* Return the absolute coordinates of the top-left corner of this element,
* Return the absolute coordinates of the top-left corner of this element,
* scales that after canvas SVG element, if it's a descendant.
* scales that after canvas SVG element, if it's a descendant.
...
...
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