-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #641 from tblivet/feat/scroll_padding
Feat: handle scroll offset on anchor links
- Loading branch information
Showing
4 changed files
with
30 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import SelectorsMap from '@constants/selectors-map'; | ||
|
||
const setScrollPaddingTop = () => { | ||
const header = document.querySelector(SelectorsMap.layout.stickyHeader) as HTMLElement; | ||
|
||
if (header) { | ||
const headerHeight = header.offsetHeight; | ||
document.documentElement.style.setProperty('scroll-padding-top', `${headerHeight}px`); | ||
} | ||
}; | ||
|
||
const initScrollPaddingTop = () => { | ||
window.addEventListener('load', setScrollPaddingTop); | ||
window.addEventListener('resize', setScrollPaddingTop); | ||
}; | ||
|
||
export default initScrollPaddingTop; |
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
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