-
-
Notifications
You must be signed in to change notification settings - Fork 480
[Tech] Update to Electron 27. Re-work scroll-related CSS #3136
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2de17ba
Update to Electron 27. Re-work scroll-related CSS
arielj 15ee811
Fix position sticky and background of headers in library
arielj ab5ae65
Merge branch 'main' of github.com:Heroic-Games-Launcher/HeroicGamesLa…
arielj 083243e
Update electron-builder
arielj 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -81,41 +81,33 @@ export default React.memo(function Library(): JSX.Element { | |
) | ||
const { t } = useTranslation() | ||
const backToTopElement = useRef(null) | ||
const listing = useRef<HTMLDivElement>(null) | ||
|
||
//Remember scroll position | ||
useLayoutEffect(() => { | ||
const scrollPosition = parseInt(storage?.getItem('scrollPosition') || '0') | ||
|
||
const storeScrollPosition = () => { | ||
storage?.setItem( | ||
'scrollPosition', | ||
listing.current?.scrollTop.toString() || '0' | ||
) | ||
storage?.setItem('scrollPosition', window.scrollY.toString() || '0') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we get the scroll from the window now, not from the listing element |
||
} | ||
|
||
listing.current?.addEventListener('scroll', storeScrollPosition) | ||
listing.current?.scrollTo(0, scrollPosition || 0) | ||
window.addEventListener('scroll', storeScrollPosition) | ||
window.scrollTo(0, scrollPosition || 0) | ||
|
||
return () => { | ||
listing.current?.removeEventListener('scroll', storeScrollPosition) | ||
window.removeEventListener('scroll', storeScrollPosition) | ||
} | ||
}, [listing.current]) | ||
}, []) | ||
|
||
// bind back to top button | ||
useEffect(() => { | ||
if (backToTopElement.current) { | ||
const listing = document.querySelector('.listing') | ||
if (listing) { | ||
listing.addEventListener('scroll', () => { | ||
const btn = document.getElementById('backToTopBtn') | ||
const topSpan = document.getElementById('top') | ||
if (btn && topSpan) { | ||
btn.style.visibility = | ||
listing.scrollTop > 450 ? 'visible' : 'hidden' | ||
} | ||
}) | ||
} | ||
window.addEventListener('scroll', () => { | ||
const btn = document.getElementById('backToTopBtn') | ||
const topSpan = document.getElementById('top') | ||
if (btn && topSpan) { | ||
btn.style.visibility = window.scrollY > 450 ? 'visible' : 'hidden' | ||
} | ||
}) | ||
} | ||
}, [backToTopElement]) | ||
|
||
|
@@ -336,6 +328,16 @@ export default React.memo(function Library(): JSX.Element { | |
showNonAvailable | ||
]) | ||
|
||
// we need this to do proper `position: sticky` of the Add Game area | ||
// the height of the Header can change at runtime with different font families | ||
useEffect(() => { | ||
const header = document.querySelector('.Header') | ||
if (header) { | ||
const headerHeight = header.getBoundingClientRect().height | ||
document.body.style.setProperty('--header-height', `${headerHeight}px`) | ||
} | ||
}, []) | ||
|
||
if (!epic && !gog && !amazon) { | ||
return ( | ||
<ErrorComponent | ||
|
@@ -351,7 +353,7 @@ export default React.memo(function Library(): JSX.Element { | |
<> | ||
<Header /> | ||
|
||
<div className="listing" ref={listing}> | ||
<div className="listing"> | ||
<span id="top" /> | ||
{showRecentGames && ( | ||
<RecentlyPlayed | ||
|
This file contains hidden or 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.
needed because of the electron upgrade