Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Pierre Boudes
mastodon
Commits
f645dad6
Unverified
Commit
f645dad6
authored
4 years ago
by
Mashiro
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add mouse scroll lock in image expand view (#15088)
* add mouse scroll lock in image expand view * enhancement
parent
6a2db10f
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
app/javascript/mastodon/features/ui/components/zoomable_image.js
+21
-19
21 additions, 19 deletions
...ascript/mastodon/features/ui/components/zoomable_image.js
with
21 additions
and
19 deletions
app/javascript/mastodon/features/ui/components/zoomable_image.js
+
21
−
19
View file @
f645dad6
...
...
@@ -194,11 +194,14 @@ class ZoomableImage extends React.PureComponent {
if
(
this
.
state
.
zoomMatrix
.
type
===
'
full-width
'
)
{
// full width, scroll vertical
this
.
container
.
scrollTop
=
this
.
container
.
scrollTop
+
event
.
pixelY
;
this
.
container
.
scrollTop
=
Math
.
max
(
this
.
container
.
scrollTop
+
event
.
pixelY
,
this
.
state
.
lockScroll
.
y
)
;
}
else
{
// full height, scroll horizontal
this
.
container
.
scrollLeft
=
this
.
container
.
scrollLeft
+
event
.
pixelY
;
this
.
container
.
scrollLeft
=
Math
.
max
(
this
.
container
.
scrollLeft
+
event
.
pixelY
,
this
.
state
.
lockScroll
.
x
)
;
}
// lock horizontal scroll
this
.
container
.
scrollLeft
=
Math
.
max
(
this
.
container
.
scrollLeft
+
event
.
pixelX
,
this
.
state
.
lockScroll
.
x
);
}
mouseDownHandler
=
e
=>
{
...
...
@@ -221,13 +224,8 @@ class ZoomableImage extends React.PureComponent {
const
dx
=
e
.
clientX
-
this
.
state
.
dragPosition
.
x
;
const
dy
=
e
.
clientY
-
this
.
state
.
dragPosition
.
y
;
if
((
this
.
state
.
dragPosition
.
left
-
dx
)
>=
this
.
state
.
lockScroll
.
x
)
{
this
.
container
.
scrollLeft
=
this
.
state
.
dragPosition
.
left
-
dx
;
}
if
((
this
.
state
.
dragPosition
.
top
-
dy
)
>=
this
.
state
.
lockScroll
.
y
)
{
this
.
container
.
scrollTop
=
this
.
state
.
dragPosition
.
top
-
dy
;
}
this
.
container
.
scrollLeft
=
Math
.
max
(
this
.
state
.
dragPosition
.
left
-
dx
,
this
.
state
.
lockScroll
.
x
);
this
.
container
.
scrollTop
=
Math
.
max
(
this
.
state
.
dragPosition
.
top
-
dy
,
this
.
state
.
lockScroll
.
y
);
this
.
setState
({
dragged
:
true
});
}
...
...
@@ -336,22 +334,26 @@ class ZoomableImage extends React.PureComponent {
const
{
scale
,
zoomMatrix
}
=
this
.
state
;
if
(
scale
>=
zoomMatrix
.
rate
)
{
this
.
setState
({
scale
:
MIN_SCALE
},
()
=>
{
this
.
container
.
scrollLeft
=
0
;
this
.
container
.
scrollTop
=
0
;
this
.
setState
({
lockScroll
:
{
this
.
setState
({
scale
:
MIN_SCALE
,
lockScroll
:
{
x
:
0
,
y
:
0
,
}
});
},
},
()
=>
{
this
.
container
.
scrollLeft
=
0
;
this
.
container
.
scrollTop
=
0
;
});
}
else
{
this
.
setState
({
scale
:
zoomMatrix
.
rate
},
()
=>
{
this
.
container
.
scrollLeft
=
zoomMatrix
.
scrollLeft
;
this
.
container
.
scrollTop
=
zoomMatrix
.
scrollTop
;
this
.
setState
({
lockScroll
:
{
this
.
setState
({
scale
:
zoomMatrix
.
rate
,
lockScroll
:
{
x
:
zoomMatrix
.
scrollLeft
,
y
:
zoomMatrix
.
scrollTop
,
}
});
},
},
()
=>
{
this
.
container
.
scrollLeft
=
zoomMatrix
.
scrollLeft
;
this
.
container
.
scrollTop
=
zoomMatrix
.
scrollTop
;
});
}
...
...
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