Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
logging-scratch-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Goessmann
logging-scratch-gui
Commits
d40ad736
Commit
d40ad736
authored
6 years ago
by
chrisgarrity
Browse files
Options
Downloads
Patches
Plain Diff
Positioning custom-procedure blocks in RTL
parent
a0d6d049
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/containers/custom-procedures.jsx
+41
-5
41 additions, 5 deletions
src/containers/custom-procedures.jsx
with
41 additions
and
5 deletions
src/containers/custom-procedures.jsx
+
41
−
5
View file @
d40ad736
...
@@ -19,6 +19,7 @@ class CustomProcedures extends React.Component {
...
@@ -19,6 +19,7 @@ class CustomProcedures extends React.Component {
'
setBlocks
'
'
setBlocks
'
]);
]);
this
.
state
=
{
this
.
state
=
{
rtlOffset
:
0
,
warp
:
false
warp
:
false
};
};
}
}
...
@@ -55,11 +56,46 @@ class CustomProcedures extends React.Component {
...
@@ -55,11 +56,46 @@ class CustomProcedures extends React.Component {
const
metrics
=
this
.
workspace
.
getMetrics
();
const
metrics
=
this
.
workspace
.
getMetrics
();
const
{
x
,
y
}
=
this
.
mutationRoot
.
getRelativeToSurfaceXY
();
const
{
x
,
y
}
=
this
.
mutationRoot
.
getRelativeToSurfaceXY
();
const
dy
=
(
metrics
.
viewHeight
/
2
)
-
(
this
.
mutationRoot
.
height
/
2
)
-
y
;
const
dy
=
(
metrics
.
viewHeight
/
2
)
-
(
this
.
mutationRoot
.
height
/
2
)
-
y
;
let
dx
=
(
metrics
.
viewWidth
/
2
)
-
(
this
.
mutationRoot
.
width
/
2
)
-
x
;
let
dx
;
// If the procedure declaration is wider than the view width,
if
(
this
.
props
.
isRtl
)
{
// keep the right-hand side of the procedure in view.
// HACK!! This is temporary until we can figure out what's going on width
if
(
this
.
mutationRoot
.
width
>
metrics
.
viewWidth
)
{
// block positioning on the workspace for RTL.
dx
=
metrics
.
viewWidth
-
this
.
mutationRoot
.
width
-
x
;
// Workspace is always origin top-left, with x increasing to the right
// Calculate initial starting offset and save it, every other move
// has to take the original offset into account.
// Calculate a new left postion based on new width
// Convert current x position into LTR (mirror) x position (uses original offset)
// Use the difference between ltrX and mirrorX as the amount to move
const
ltrX
=
((
metrics
.
viewWidth
/
2
)
-
(
this
.
mutationRoot
.
width
/
2
)
+
25
);
const
mirrorX
=
x
-
((
x
-
this
.
state
.
rtlOffset
)
*
2
);
if
(
mirrorX
===
ltrX
)
{
return
;
}
dx
=
mirrorX
-
ltrX
;
const
midPoint
=
metrics
.
viewWidth
/
2
;
if
(
x
===
0
)
{
// if it's the first time positioning, it should always move right
if
(
this
.
mutationRoot
.
width
<
midPoint
)
{
dx
=
ltrX
;
}
else
if
(
this
.
mutationRoot
.
width
<
metrics
.
viewWidth
)
{
dx
=
midPoint
-
((
metrics
.
viewWidth
-
this
.
mutationRoot
.
width
)
/
2
);
}
else
{
dx
=
midPoint
+
(
this
.
mutationRoot
.
width
-
metrics
.
viewWidth
);
}
this
.
mutationRoot
.
moveBy
(
dx
,
dy
);
this
.
setState
({
rtlOffset
:
this
.
mutationRoot
.
getRelativeToSurfaceXY
().
x
});
return
;
}
if
(
this
.
mutationRoot
.
width
>
metrics
.
viewWidth
)
{
dx
=
dx
+
this
.
mutationRoot
.
width
-
metrics
.
viewWidth
;
}
}
else
{
dx
=
(
metrics
.
viewWidth
/
2
)
-
(
this
.
mutationRoot
.
width
/
2
)
-
x
;
// If the procedure declaration is wider than the view width,
// keep the right-hand side of the procedure in view.
if
(
this
.
mutationRoot
.
width
>
metrics
.
viewWidth
)
{
dx
=
metrics
.
viewWidth
-
this
.
mutationRoot
.
width
-
x
;
}
}
}
this
.
mutationRoot
.
moveBy
(
dx
,
dy
);
this
.
mutationRoot
.
moveBy
(
dx
,
dy
);
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment