mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Add spread modes to web viewer
This builds on the scrolling mode work to add three buttons for joining page spreads together: one for the default view, with no page spreads, and two for spreads starting on odd-numbered or even-numbered pages.
This commit is contained in:
parent
91cbc185da
commit
3d83c646c6
16 changed files with 168 additions and 25 deletions
|
@ -13,9 +13,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ScrollMode, SpreadMode } from './base_viewer';
|
||||
import { CursorTool } from './pdf_cursor_tools';
|
||||
import { SCROLLBAR_PADDING } from './ui_utils';
|
||||
import { ScrollMode } from './base_viewer';
|
||||
|
||||
/**
|
||||
* @typedef {Object} SecondaryToolbarOptions
|
||||
|
@ -83,6 +83,12 @@ class SecondaryToolbar {
|
|||
eventDetails: { mode: ScrollMode.HORIZONTAL, }, close: true, },
|
||||
{ element: options.scrollWrappedButton, eventName: 'switchscrollmode',
|
||||
eventDetails: { mode: ScrollMode.WRAPPED, }, close: true, },
|
||||
{ element: options.spreadNoneButton, eventName: 'switchspreadmode',
|
||||
eventDetails: { mode: SpreadMode.NONE, }, close: true, },
|
||||
{ element: options.spreadOddButton, eventName: 'switchspreadmode',
|
||||
eventDetails: { mode: SpreadMode.ODD, }, close: true, },
|
||||
{ element: options.spreadEvenButton, eventName: 'switchspreadmode',
|
||||
eventDetails: { mode: SpreadMode.EVEN, }, close: true, },
|
||||
{ element: options.documentPropertiesButton,
|
||||
eventName: 'documentproperties', close: true, },
|
||||
];
|
||||
|
@ -102,10 +108,12 @@ class SecondaryToolbar {
|
|||
|
||||
this.reset();
|
||||
|
||||
// Bind the event listeners for click, cursor tool, and scroll mode actions.
|
||||
// Bind the event listeners for click, cursor tool, and scroll/spread mode
|
||||
// actions.
|
||||
this._bindClickListeners();
|
||||
this._bindCursorToolsListener(options);
|
||||
this._bindScrollModeListener(options);
|
||||
this._bindSpreadModeListener(options);
|
||||
|
||||
// Bind the event listener for adjusting the 'max-height' of the toolbar.
|
||||
this.eventBus.on('resize', this._setMaxHeight.bind(this));
|
||||
|
@ -191,6 +199,17 @@ class SecondaryToolbar {
|
|||
});
|
||||
}
|
||||
|
||||
_bindSpreadModeListener(buttons) {
|
||||
this.eventBus.on('spreadmodechanged', function(evt) {
|
||||
buttons.spreadNoneButton.classList.toggle('toggled',
|
||||
evt.mode === SpreadMode.NONE);
|
||||
buttons.spreadOddButton.classList.toggle('toggled',
|
||||
evt.mode === SpreadMode.ODD);
|
||||
buttons.spreadEvenButton.classList.toggle('toggled',
|
||||
evt.mode === SpreadMode.EVEN);
|
||||
});
|
||||
}
|
||||
|
||||
open() {
|
||||
if (this.opened) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue