mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Refactor toolbar (and secondary toolbar).
This commit is contained in:
parent
043cea251d
commit
a4402c84de
7 changed files with 457 additions and 231 deletions
|
@ -28,6 +28,8 @@
|
|||
var CSS_UNITS = 96.0 / 72.0;
|
||||
var DEFAULT_SCALE_VALUE = 'auto';
|
||||
var DEFAULT_SCALE = 1.0;
|
||||
var MIN_SCALE = 0.25;
|
||||
var MAX_SCALE = 10.0;
|
||||
var UNKNOWN_SCALE = 0;
|
||||
var MAX_AUTO_SCALE = 1.25;
|
||||
var SCROLLBAR_PADDING = 40;
|
||||
|
@ -122,7 +124,7 @@ function getOutputScale(ctx) {
|
|||
function scrollIntoView(element, spot, skipOverflowHiddenElements) {
|
||||
// Assuming offsetParent is available (it's not available when viewer is in
|
||||
// hidden iframe or object). We have to scroll: if the offsetParent is not set
|
||||
// producing the error. See also animationStartedClosure.
|
||||
// producing the error. See also animationStarted.
|
||||
var parent = element.offsetParent;
|
||||
if (!parent) {
|
||||
console.error('offsetParent is not set -- cannot scroll');
|
||||
|
@ -408,6 +410,30 @@ function normalizeWheelEventDelta(evt) {
|
|||
return delta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Promise that is resolved when DOM window becomes visible.
|
||||
*/
|
||||
var animationStarted = new Promise(function (resolve) {
|
||||
window.requestAnimationFrame(resolve);
|
||||
});
|
||||
|
||||
/**
|
||||
* Promise that is resolved when UI localization is finished.
|
||||
*/
|
||||
var localized = new Promise(function (resolve, reject) {
|
||||
if (!mozL10n) {
|
||||
reject(new Error('mozL10n service is not available.'));
|
||||
return;
|
||||
}
|
||||
if (mozL10n.getReadyState() !== 'loading') {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
window.addEventListener('localized', function localized(evt) {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Simple event bus for an application. Listeners are attached using the
|
||||
* `on` and `off` methods. To raise an event, the `dispatch` method shall be
|
||||
|
@ -536,6 +562,8 @@ var ProgressBar = (function ProgressBarClosure() {
|
|||
exports.CSS_UNITS = CSS_UNITS;
|
||||
exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
|
||||
exports.DEFAULT_SCALE = DEFAULT_SCALE;
|
||||
exports.MIN_SCALE = MIN_SCALE;
|
||||
exports.MAX_SCALE = MAX_SCALE;
|
||||
exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
|
||||
exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
|
||||
exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
|
||||
|
@ -554,4 +582,6 @@ exports.scrollIntoView = scrollIntoView;
|
|||
exports.watchScroll = watchScroll;
|
||||
exports.binarySearchFirstItem = binarySearchFirstItem;
|
||||
exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
|
||||
exports.animationStarted = animationStarted;
|
||||
exports.localized = localized;
|
||||
}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue