-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Titles sticky to menubar instead of document top #9584
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
Open
BurningTreeC
wants to merge
9
commits into
TiddlyWiki:master
Choose a base branch
from
BurningTreeC:titles-sticky-to-menubar
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+94
−1
Open
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5f9b295
Update styles.tid to use --tc-menubar-height variable
BurningTreeC fd010d4
Create startup.js - menubar-height-tracker
BurningTreeC 68313a7
Update startup.js
BurningTreeC 879aeb5
Create #9584 - stick stickytitles to menubar.tid
BurningTreeC 346df5b
Update startup.js - change variable name to --tv-*
BurningTreeC c46be54
Update styles.tid
BurningTreeC 101aac8
Update startup.js
BurningTreeC 242e02b
Change menubarObserver to local variable in startup
BurningTreeC 2adb14e
Merge branch 'TiddlyWiki:master' into titles-sticky-to-menubar
BurningTreeC 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
13 changes: 13 additions & 0 deletions
13
editions/tw5.com/tiddlers/releasenotes/5.4.0/#9584 - stick stickytitles to menubar.tid
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| title: $:/changenotes/5.4.0/#9584 | ||
| created: 20260116062202184 | ||
| modified: 20260116062202184 | ||
| tags: $:/tags/ChangeNote | ||
| change-type: enhancement | ||
| change-category: usability | ||
| description: The sticky tiddler titles account for the menubar | ||
| release: 5.4.0 | ||
| github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9584 | ||
| github-contributors: BurningTreeC | ||
| type: text/vnd.tiddlywiki | ||
|
|
||
| This change makes the sticky tiddler titles stick to the menubar if present instead of sticking to the top of the document and being hidden by the menubar |
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 |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /*\ | ||
| title: $:/plugins/tiddlywiki/menubar/startup.js | ||
| type: application/javascript | ||
| module-type: startup | ||
|
|
||
| Startup module to track menubar height and set CSS variable for sticky positioning | ||
|
|
||
| \*/ | ||
|
|
||
| "use strict"; | ||
|
|
||
| exports.name = "menubar-height-tracker"; | ||
| exports.platforms = ["browser"]; | ||
| exports.after = ["startup"]; | ||
| exports.synchronous = true; | ||
|
|
||
| var menubarObserver = null; | ||
|
Check warning on line 17 in plugins/tiddlywiki/menubar/startup.js
|
||
|
|
||
| exports.startup = function() { | ||
| var menubarObserver = null; | ||
| var isTracking = false; | ||
|
|
||
| function updateMenubarHeight(menubar) { | ||
| var computedStyle = window.getComputedStyle(menubar); | ||
| var position = computedStyle.position; | ||
| var isOverlapping = position === "fixed" || position === "sticky" || position === "absolute"; | ||
| if(isOverlapping) { | ||
| var height = menubar.getBoundingClientRect().height; | ||
| document.documentElement.style.setProperty("--tv-menubar-height", height + "px"); | ||
| } else { | ||
| document.documentElement.style.setProperty("--tv-menubar-height", "0px"); | ||
| } | ||
| } | ||
|
|
||
| function setupMenubarTracking(menubar) { | ||
| if(isTracking) return; | ||
| isTracking = true; | ||
|
|
||
| updateMenubarHeight(menubar); | ||
|
|
||
| if(typeof ResizeObserver !== "undefined") { | ||
| menubarObserver = new ResizeObserver(function() { | ||
| updateMenubarHeight(menubar); | ||
| }); | ||
| menubarObserver.observe(menubar); | ||
| } | ||
|
|
||
| window.addEventListener("resize", function() { | ||
| updateMenubarHeight(menubar); | ||
| }); | ||
| } | ||
|
|
||
| function checkForMenubar() { | ||
| var menubar = document.querySelector(".tc-menubar.tc-adjust-top-of-scroll"); | ||
| if(menubar) { | ||
| setupMenubarTracking(menubar); | ||
| } else { | ||
| document.documentElement.style.setProperty("--tv-menubar-height", "0px"); | ||
| } | ||
| } | ||
|
|
||
| // Initial check | ||
| checkForMenubar(); | ||
|
|
||
| // Re-check after wiki changes (DOM updates after refresh cycle) | ||
| if(!isTracking) { | ||
| $tw.wiki.addEventListener("change", function() { | ||
| if(!isTracking) { | ||
| $tw.utils.nextTick(checkForMenubar); | ||
| } | ||
| }); | ||
| } | ||
| }; | ||
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.
Uh oh!
There was an error while loading. Please reload this page.