Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Prevent extra multi image page padding added by preview consumers #854

Merged
merged 1 commit into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const CLASS_BOX_PREVIEW_THEME_DARK = 'bp-theme-dark';
export const CLASS_ELEM_KEYBOARD_FOCUS = 'bp-has-keyboard-focus';
export const CLASS_FULLSCREEN = 'bp-is-fullscreen';
export const CLASS_FULLSCREEN_UNSUPPORTED = 'bp-fullscreen-unsupported';
export const CLASS_MULTI_IMAGE_PAGE = 'bp-multi-image-page';
export const CLASS_INVISIBLE = 'bp-is-invisible';
export const CLASS_IS_TRANSPARENT = 'bp-is-transparent';
export const CLASS_IS_VISIBLE = 'bp-is-visible';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/viewers/image/MultiImageViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ImageBaseViewer from './ImageBaseViewer';
import PageControls from '../../PageControls';
import './MultiImage.scss';
import { ICON_FULLSCREEN_IN, ICON_FULLSCREEN_OUT } from '../../icons/icons';
import { CLASS_INVISIBLE } from '../../constants';
import { CLASS_INVISIBLE, CLASS_MULTI_IMAGE_PAGE } from '../../constants';
import { pageNumberFromScroll } from '../../util';

const PADDING_BUFFER = 100;
Expand Down Expand Up @@ -143,7 +143,7 @@ class MultiImageViewer extends ImageBaseViewer {

// Set page number. Page is index + 1.
this.singleImageEls[index].setAttribute('data-page-number', index + 1);
this.singleImageEls[index].classList.add('page');
this.singleImageEls[index].classList.add(CLASS_MULTI_IMAGE_PAGE);

this.singleImageEls[index].src = imageUrl;
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/viewers/image/__tests__/MultiImageViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import MultiImageViewer from '../MultiImageViewer';
import PageControls from '../../../PageControls';
import fullscreen from '../../../Fullscreen';
import { CLASS_MULTI_IMAGE_PAGE } from '../../../constants';
import BaseViewer from '../../BaseViewer';
import ImageBaseViewer from '../ImageBaseViewer';
import Browser from '../../../Browser';
Expand Down Expand Up @@ -226,7 +227,7 @@ describe('lib/viewers/image/MultiImageViewer', () => {
multiImage.singleImageEls = [stubs.singleImageEl];

multiImage.setupImageEls('file/100/content/{page}.png', 0);
expect(stubs.singleImageEl.classList.add).to.be.calledWith('page');
expect(stubs.singleImageEl.classList.add).to.be.calledWith(CLASS_MULTI_IMAGE_PAGE);
});
});

Expand Down