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
2f86fc5e
Commit
2f86fc5e
authored
6 years ago
by
Les Orchard
Committed by
Eugen Rochko
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Identify manual scrolling to cancel scroll to top reset on mouse idle (#9245)
parent
08b3de4d
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/components/scrollable_list.js
+17
-6
17 additions, 6 deletions
app/javascript/mastodon/components/scrollable_list.js
with
17 additions
and
6 deletions
app/javascript/mastodon/components/scrollable_list.js
+
17
−
6
View file @
2f86fc5e
...
...
@@ -59,6 +59,13 @@ export default class ScrollableList extends PureComponent {
}
else
if
(
this
.
props
.
onScroll
)
{
this
.
props
.
onScroll
();
}
if
(
!
this
.
lastScrollWasSynthetic
)
{
// If the last scroll wasn't caused by setScrollTop(), assume it was
// intentional and cancel any pending scroll reset on mouse idle
this
.
scrollToTopOnMouseIdle
=
false
;
}
this
.
lastScrollWasSynthetic
=
false
;
}
},
150
,
{
trailing
:
true
,
...
...
@@ -66,8 +73,16 @@ export default class ScrollableList extends PureComponent {
mouseIdleTimer
=
null
;
mouseMovedRecently
=
false
;
lastScrollWasSynthetic
=
false
;
scrollToTopOnMouseIdle
=
false
;
setScrollTop
=
newScrollTop
=>
{
if
(
this
.
node
.
scrollTop
!==
newScrollTop
)
{
this
.
lastScrollWasSynthetic
=
true
;
this
.
node
.
scrollTop
=
newScrollTop
;
}
};
clearMouseIdleTimer
=
()
=>
{
if
(
this
.
mouseIdleTimer
===
null
)
{
return
;
...
...
@@ -99,7 +114,7 @@ export default class ScrollableList extends PureComponent {
handleMouseIdle
=
()
=>
{
if
(
this
.
scrollToTopOnMouseIdle
)
{
this
.
node
.
s
crollTop
=
0
;
this
.
setS
crollTop
(
0
)
;
}
this
.
mouseMovedRecently
=
false
;
...
...
@@ -132,11 +147,7 @@ export default class ScrollableList extends PureComponent {
// Reset the scroll position when a new child comes in in order not to
// jerk the scrollbar around if you're already scrolled down the page.
if
(
snapshot
!==
null
)
{
const
newScrollTop
=
this
.
node
.
scrollHeight
-
snapshot
;
if
(
this
.
node
.
scrollTop
!==
newScrollTop
)
{
this
.
node
.
scrollTop
=
newScrollTop
;
}
this
.
setScrollTop
(
this
.
node
.
scrollHeight
-
snapshot
);
}
}
...
...
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