mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-21 10:45:20 -04:00
Fix smooth scroll and other bugs (#1861)
This PR fixes: - The wrong clean up of window post message communicators - The smooth scroll bug in chrome (Fixes Anchor navigation in render view not working #1770) - Scroll by using touch devices in renderer - Lazy loading of the editor (code mirror doesn't need to be lazy loaded any more)
This commit is contained in:
parent
0f3f7a82b5
commit
8b4e9191e5
15 changed files with 260 additions and 213 deletions
|
@ -14,7 +14,14 @@ export interface JumpAnchorProps extends AllHTMLAttributes<HTMLAnchorElement> {
|
|||
export const JumpAnchor: React.FC<JumpAnchorProps> = ({ jumpTargetId, children, ...props }) => {
|
||||
const jumpToTargetId = useCallback(
|
||||
(event: React.MouseEvent<HTMLElement, MouseEvent>): void => {
|
||||
document.getElementById(jumpTargetId)?.scrollIntoView({ behavior: 'smooth' })
|
||||
const intoViewElement = document.getElementById(jumpTargetId)
|
||||
const scrollElement = document.querySelector('[data-scroll-element]')
|
||||
if (!intoViewElement || !scrollElement) {
|
||||
return
|
||||
}
|
||||
//It would be much easier to use scrollIntoView here but since the code mirror also uses smooth scroll and bugs like
|
||||
// https://stackoverflow.com/a/63563437/13103995 exist, we must use scrollTo.
|
||||
scrollElement.scrollTo({ behavior: 'smooth', top: intoViewElement.offsetTop })
|
||||
event.preventDefault()
|
||||
},
|
||||
[jumpTargetId]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue