Skip to content

Commit

Permalink
Fix: Resize preview when thumbnails open
Browse files Browse the repository at this point in the history
The initial resize may happen before the document is ready, so resizing when we decleare the document 'loaded' will ensure that the document is resized and not the preload image. The initial resize is preserved so that preload image will be resized when the thumbnails open.
  • Loading branch information
Jeremy Press authored Jun 5, 2019
1 parent a8a7d44 commit 01c549b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/viewers/doc/DocBaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ class DocBaseViewer extends BaseViewer {

if (this.options.enableThumbnailsSidebar) {
this.initThumbnails();
this.resize();
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/viewers/doc/__tests__/DocBaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,7 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => {
stubs.emit = sandbox.stub(docBase, 'emit');
stubs.initThumbnails = sandbox.stub(docBase, 'initThumbnails');
stubs.hidePreload = sandbox.stub(docBase, 'hidePreload');
stubs.resize = sandbox.stub(docBase, 'resize');
});

it('should emit the pagerender event', () => {
Expand All @@ -1808,6 +1809,7 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => {
expect(stubs.initThumbnails).to.be.called;
expect(stubs.hidePreload).to.be.called;
expect(docBase.somePageRendered).to.be.true;
expect(docBase.resize).to.be.called;
});

it('should not init thumbnails if not enabled', () => {
Expand Down

0 comments on commit 01c549b

Please sign in to comment.