-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Imrove scroll behavior to hash issuecomment(scroll position, auto expand if file is folded, and on refreshing) #23513
Merged
Merged
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f5ec800
scroll to viewed comment
HesterG 9d4b530
Merge branch 'go-gitea:main' into viewed-file-scroll
HesterG a8a1d57
Merge branch 'go-gitea:main' into viewed-file-scroll
HesterG 08b8c0c
forget pos remember when having hash
HesterG 63892e8
add condition
HesterG 40dc855
add comments
HesterG 8feda9d
update comment
HesterG 43113ee
fix lint
HesterG e0c9898
fix lint
HesterG a46b186
Merge branch 'main' into viewed-file-scroll
HesterG 7bea4fc
use scrolltop
HesterG 21b02fa
use scrolltop
HesterG 323b10d
Merge branch 'main' into viewed-file-scroll
HesterG 5aef97a
use height instead of hard code
HesterG 6e20865
use jquery
HesterG 32d3eea
use outerheight
HesterG 522fa67
Merge branch 'main' into viewed-file-scroll
HesterG 59e98c9
use window.scrollto
HesterG 96f267d
Merge branch 'main' into viewed-file-scroll
HesterG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why two selectors? The
scrollTop
should be invoked on a clear target IMO.ps: I just thought it's a good chance to rewrite all the legacy jQuery code to Vanilla JS 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://stackoverflow.com/questions/12222485/why-to-use-html-body-for-scrolltop-instead-of-just-html
For the two selectors, I saw this. I think it might be a good idea as we are also using vue, and it sometimes feels strange to have jquery at the same time. But I think I still lack an overall view to the product to comment on this right now..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that's too old, 10 years ago ... I do not think Gitea supports so old browsers. What's the modern and proper approach, by MDN?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
html
akadocument.documentElement
is sufficient, tested on try.gitea.io:So if you want to scroll the page in JS to a certain offset:
Thought I generally recommend
Element.scrollIntoView()
instead of scrolling to calculated offsets, if that is an option here, but I think it isn't. Or even better, let browser-native anchor scrolling take effect.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
scrollIntoView
cannot set offset value, added a commit to usewindow.scrollto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good as well.