The-Fox--Only-Better
The-Fox--Only-Better copied to clipboard
The toolbars hide too soon before "something" finishes
Normally, the toolbars will stay visible (or will be shown if they are invisible at the time) when there is something happening in them. For example, when you click the star button to bookmark a page, the toolbars won't hide until the little animation finishes. Or if a download finishes, the toolbars will be shown, so that the downloads indicator can notify you of it.
If you find any instance where the toolbars should remain visible for longer, or they don't show at all, when some firefox operation that requires them happens, please let me know by opening a new issue or posting in this thread, and I'll try to fix it as soon as possible.
If this operation comes from another add-on, please try to contact its developer first, and direct them to this thread, as they better than anyone will know what/when/where needs to happen. Only if you can't reach them for some reason, let me know and I'll see what I can do.
For add-on developers
Say that, for example, you have a toolbar button that animates to notify the user that an action has concluded. Of course this requires the toolbars to be shown, and remain visible until the animation finishes. This is easily achievable from outside of TheFOB.
For this, the add-on provides an initialShowChrome() method, accessible from an window object as window.theFoxOnlyBetter.initialShowChrome(delay)
where delay
is an optional integer argument in miliseconds, where if omitted will default to 3000.
Through this method, you can ensure that the toolbars remain visible for at least the time you specify; in the example I gave, this usually is time it takes for the animation to finish.
Usually, you would also want to wait until the toolbars are fully visible before starting the animation. When this happens, an 'FinishedSlimChromeWidth' event is fired, which you can listen to and proceed with the animation when it fires.
Basically, your code would look something like this:
var waitingForSlimChrome = false;
function doAnimation() { /* do the actual animation */ }
/* this is the method you would call to do the animation, instead of calling
doAnimation() directly */
function prepareAnimation() {
/* check if TheFOB and its slimChrome feature are both enabled
(it not always is) */
if(window.theFoxOnlyBetter && window.theFoxOnlyBetter.slimChromeContainer) {
/* if we're already waiting for chrome to show, there's no need to
call this again */
if(waitingForSlimChrome) { return; }
/* only show the chrome if the button is in its toolbars, you could check
the button's parentNode, or the widget's position through the
CustomizableUI APIs, or any other way you want (I'm checking parentNode
here as an example) */
var inSlimChrome = false;
var check = document.getElementById('myButton');
while(check.parentNode) {
check = check.parentNode;
if(check == window.theFoxOnlyBetter.slimChromeContainer) {
inSlimChrome = true;
break;
}
}
if(inSlimChrome) {
/* if the toolbars are hidden, pause/delay the animation until
they are visible */
if(window.theFoxOnlyBetter.slimChromeContainer
.getAttribute('hover') != 'true') {
waitingForSlimChrome = true;
window.theFoxOnlyBetter.initialShowChrome();
return;
}
/* if the toolbars are already visible, make sure they remain visible
until the animation is finished; setting 2s as an example only */
window.theFoxOnlyBetter.initialShowChrome(2000);
}
}
/* proceed with the animation */
doAnimation();
}
/* the listener that will command the animation when the chrome is finished
showing and is already fully visible */
function proceedWithAnimation() {
if(waitingForSlimChrome) {
waitingForSlimChrome = false;
doAnimation();
}
}
window.addEventListener('FinishedSlimChromeWidth', proceedWithAnimation);
You can see examples of how I do this for the downloads-indicator and for the bookmarked animation in https://github.com/Quicksaver/The-Fox--Only-Better/blob/master/resource/modules/compatibilityFix/downloadsIndicator.jsm and in https://github.com/Quicksaver/The-Fox--Only-Better/blob/master/resource/modules/compatibilityFix/bookmarkedItem.jsm.
If you have any questions or need help with anything please let me know, and I'll do my best to help in any way that I can.