mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
[GeckoView] Show the download button by default and add a pref to disable it (bug 1827963)
For the moment there is no real consensus on how we should download a pdf on Android. Hence we keep this solution for the moment but behind a pref (which will be true on nightly only).
This commit is contained in:
parent
7571842d84
commit
7f0d45ce47
4 changed files with 61 additions and 23 deletions
|
@ -20,16 +20,24 @@
|
|||
* @property {HTMLButtonElement} download - Button to download the document.
|
||||
*/
|
||||
|
||||
const TIME_BEFORE_SHOWING_TOOLBAR = 200;
|
||||
|
||||
class Toolbar {
|
||||
#buttons;
|
||||
|
||||
#checkForScrollEndBound = this.#checkForScrollEnd.bind(this);
|
||||
|
||||
#eventBus;
|
||||
|
||||
#toolbar;
|
||||
#hideBound = this.#hide.bind(this);
|
||||
|
||||
#mainContainer;
|
||||
|
||||
#toggleBound = this.toggle.bind(this);
|
||||
#scrollEndTimeoutId = null;
|
||||
|
||||
#showBound = this.#show.bind(this);
|
||||
|
||||
#toolbar;
|
||||
|
||||
/**
|
||||
* @param {ToolbarOptions} options
|
||||
|
@ -44,6 +52,7 @@ class Toolbar {
|
|||
|
||||
// Bind the event listeners for click and various other actions.
|
||||
this.#bindListeners(options);
|
||||
this.#checkForScrollEnd();
|
||||
}
|
||||
|
||||
setPageNumber(pageNumber, pageLabel) {}
|
||||
|
@ -67,12 +76,34 @@ class Toolbar {
|
|||
|
||||
updateLoadingIndicatorState(loading = false) {}
|
||||
|
||||
toggle() {
|
||||
if (this.#toolbar.classList.toggle("show")) {
|
||||
this.#mainContainer.addEventListener("scroll", this.#toggleBound);
|
||||
} else {
|
||||
this.#mainContainer.removeEventListener("scroll", this.#toggleBound);
|
||||
#checkForScrollEnd() {
|
||||
if (this.#scrollEndTimeoutId !== null) {
|
||||
clearTimeout(this.#scrollEndTimeoutId);
|
||||
}
|
||||
this.#scrollEndTimeoutId = setTimeout(
|
||||
this.#showBound,
|
||||
TIME_BEFORE_SHOWING_TOOLBAR
|
||||
);
|
||||
}
|
||||
|
||||
#show() {
|
||||
this.#toolbar.classList.toggle("show", true);
|
||||
this.#mainContainer.removeEventListener(
|
||||
"scroll",
|
||||
this.#checkForScrollEndBound
|
||||
);
|
||||
this.#scrollEndTimeoutId = null;
|
||||
this.#mainContainer.addEventListener("scroll", this.#hideBound);
|
||||
}
|
||||
|
||||
#hide() {
|
||||
this.#toolbar.classList.toggle("show", false);
|
||||
this.#mainContainer.removeEventListener("scroll", this.#hideBound);
|
||||
this.#mainContainer.addEventListener(
|
||||
"scroll",
|
||||
this.#checkForScrollEndBound
|
||||
);
|
||||
this.#checkForScrollEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue