-
Notifications
You must be signed in to change notification settings - Fork 26
Few ideas for fluentRevealNavbar.uc.js #77
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
base: master
Are you sure you want to change the base?
Changes from 24 commits
d7bc621
0cc13b7
0f5df53
e45dba3
130957e
293cc72
75f9e8d
ab69194
a0dec4f
aeceba5
73c0482
77bf366
8126494
7af0251
97905a7
d1091d5
94dc10c
2179e71
4586237
a2cfeb5
0c82178
af6d576
96f3ba2
4cf3620
aeb10b2
cd09975
0c96706
819fd64
91c0217
e2aa84f
3fafeff
36a2814
80ac4bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,14 +16,28 @@ | |
| // if true, show the effect on bookmarks on the toolbar | ||
| includeBookmarks: true, | ||
|
|
||
| // if true, show the effect on the urlbar | ||
| includeUrlBar: true, | ||
|
|
||
| // the color of the gradient. default is sort of a faint baby blue. you may prefer just white, e.g. hsla(0, 0%, 100%, 0.05) | ||
| lightColor: "hsla(224, 100%, 80%, 0.15)", | ||
| // lightColor: "hsla(224, 100%, 80%, 0.15)", | ||
emvaized marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // the color of the gradient. default is the browser's color on navbar button hover, or a faint baby blue if it's not available. | ||
| // you may prefer just white, e.g. hsla(0, 0%, 100%, 0.05) | ||
| lightColor: "var(--button-hover-bgcolor, hsla(224, 100%, 80%, 0.15))", | ||
|
|
||
| // how wide the radial gradient is. | ||
| gradientSize: 50, | ||
|
|
||
| // whether to show an additional light burst when clicking an element. (not recommended) | ||
| clickEffect: false, | ||
|
|
||
| // don't process mouse movements greater than {gradientSize}px from top of the screen, in order to reduce system load. | ||
| // disable if you modified the ui to have toolbar buttons on different side of the screen (left, right or bottom) | ||
| filterDy: true, | ||
aminomancer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
emvaized marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // looks for all toolbar buttons only once on script startup — reduces system load, but requires browser restart if toolbar buttons were changed | ||
| cacheButtons: false, | ||
| }; | ||
|
|
||
| // instantiate the handler for a given window | ||
|
|
@@ -38,15 +52,24 @@ | |
|
|
||
| // get all the toolbar buttons in the navbar, in iterable form | ||
| get toolbarButtons() { | ||
| let buttons = Array.from( | ||
| gNavToolbox.querySelectorAll(".toolbarbutton-1") | ||
| ); | ||
| if (this._options.includeBookmarks) { | ||
| buttons = buttons.concat( | ||
| Array.from(this.placesToolbarItems.querySelectorAll(".bookmark-item")) | ||
| if (!this._toolbarButtons || this._options.cacheButtons == false) { | ||
emvaized marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this._toolbarButtons = Array.from( | ||
| gNavToolbox.querySelectorAll(".toolbarbutton-1") | ||
| ); | ||
| if (this._options.includeUrlBar) { | ||
| this._toolbarButtons.push(gNavToolbox.querySelector("#urlbar-background")); | ||
| } | ||
| if (this._options.includeBookmarks) { | ||
| this._toolbarButtons = this._toolbarButtons.concat( | ||
| Array.from( | ||
| this.personalToolbar.querySelectorAll( | ||
| ".toolbarbutton-1, .bookmark-item" | ||
| ) | ||
| ) | ||
| ); | ||
| } | ||
| } | ||
| return buttons; | ||
| return this._toolbarButtons; | ||
| } | ||
|
|
||
| get placesToolbarItems() { | ||
emvaized marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
emvaized marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
@@ -58,11 +81,37 @@ | |
| ); | ||
| } | ||
|
|
||
| get personalToolbar() { | ||
| return ( | ||
| this._personalToolbar || | ||
| (this._personalToolbar = document.getElementById("PersonalToolbar")) | ||
| ); | ||
| } | ||
|
|
||
| get browser() { | ||
| return ( | ||
| this._browser || | ||
| (this._browser = document.getElementById("browser")) | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * main event handler. handles all the mouse behavior. | ||
| * @param {object} e (event) | ||
| */ | ||
| handleEvent(e) { | ||
| /// filter out mouse events which are too far from toolbar to cause any actual redraw | ||
| /// value is {gradientSize} + some additional padding to make sure effect fully clears out | ||
| if ( | ||
| this._options.filterDy && | ||
| e.clientY > | ||
| this.browser.getBoundingClientRect().y + | ||
| this._options.gradientSize | ||
| ) { | ||
| if (this._someEffectsApplied) this.clearEffectsForAll(); | ||
| return; | ||
| } | ||
|
|
||
| requestAnimationFrame(time => { | ||
| switch (e.type) { | ||
| case "scroll": | ||
|
|
@@ -135,10 +184,17 @@ | |
| let { gradientSize, lightColor } = this._options; | ||
| let isBookmark = | ||
| el.id === "PlacesChevron" || el.classList.contains("bookmark-item"); | ||
| let area = isBookmark | ||
| let area = isBookmark | ||
emvaized marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ? el | ||
| : el.querySelector(".toolbarbutton-badge-stack") || | ||
| el.querySelector(".toolbarbutton-icon"); | ||
| : el.querySelector(".toolbarbutton-badge-stack") || | ||
| el.querySelector(".toolbarbutton-icon"); | ||
| if (!area && el.id == "urlbar-background") area = el; | ||
emvaized marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // don't apply effect to focused url bar | ||
| if (this._options.includeUrlBar && el.id == 'urlbar-background' && window.gURLBar.focused) { | ||
emvaized marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return this.clearEffect(area); | ||
| } | ||
|
|
||
| let areaStyle = getComputedStyle(area); | ||
| if ( | ||
| areaStyle.display == "none" || | ||
|
|
@@ -149,7 +205,8 @@ | |
| area = el.querySelector(".toolbarbutton-text"); | ||
| } | ||
|
|
||
| if (el.disabled || areaStyle.pointerEvents == "none") { | ||
| // previous pointerEvents check may break the effect in FF 115 | ||
emvaized marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (el.disabled || getComputedStyle(el).pointerEvents == "none") { | ||
| return this.clearEffect(area); | ||
| } | ||
|
|
||
|
Owner
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. The code below needs to be fixed, or there is a bug when you move the mouse around the top of the page on about:config or about:preferences, etc. It's because they are in the parent process so their true event targets pass all the way up to the chrome window listener (normally the event target we see would be It's better if we just use MousePosTracker. let x = MousePosTracker._x - this.getOffset(area).left - window.scrollX;
let y = MousePosTracker._y - this.getOffset(area).top - window.scrollY;
Author
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. Sorry, I didn't know about this bug, so my first thought was this check was added just for UX convenience. So now this should be handled by new |
||
|
|
@@ -180,6 +237,7 @@ | |
| * @param {boolean} click (whether the left mouse button is down) | ||
| */ | ||
| generateEffectsForAll(e, click = false) { | ||
| this._someEffectsApplied = true; | ||
emvaized marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this.toolbarButtons.forEach(button => | ||
| this.generateToolbarButtonEffect(button, e, click) | ||
| ); | ||
|
|
@@ -232,6 +290,16 @@ | |
| this._options.is_pressed = false; | ||
| el.style.removeProperty("background-image"); | ||
| } | ||
|
|
||
| /** | ||
| * invoked once when {filterDy} option enabled, and cursor leaves the interactive area | ||
| */ | ||
| clearEffectsForAll() { | ||
| this._someEffectsApplied = false; | ||
| this.toolbarButtons.forEach(button => | ||
| this.clearEffect(button) | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| function init() { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.