Skip to content

Commit

Permalink
Fix: mobile audio controls overlap with navigation (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanDeMicco authored Jan 18, 2018
1 parent 3805904 commit a7ed4fc
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/lib/PreviewUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
CLASS_INVISIBLE,
CLASS_BOX_PREVIEW_BASE_HEADER,
CLASS_BOX_PREVIEW_HAS_HEADER,
CLASS_BOX_PREVIEW_HAS_NAVIGATION,
CLASS_BOX_PREVIEW_HEADER,
CLASS_BOX_PREVIEW_THEME_DARK,
CLASS_PREVIEW_LOADED,
Expand Down Expand Up @@ -157,6 +158,7 @@ class PreviewUI {
// Hide the arrows by default
leftNavEl.classList.add(CLASS_HIDDEN);
rightNavEl.classList.add(CLASS_HIDDEN);
this.contentContainer.classList.remove(CLASS_BOX_PREVIEW_HAS_NAVIGATION);

leftNavEl.removeEventListener('click', this.leftHandler);
rightNavEl.removeEventListener('click', this.rightHandler);
Expand All @@ -167,6 +169,8 @@ class PreviewUI {
return;
}

this.contentContainer.classList.add(CLASS_BOX_PREVIEW_HAS_NAVIGATION);

this.contentContainer.addEventListener('mousemove', this.mousemoveHandler);

// Selectively show or hide the navigation arrows
Expand Down
13 changes: 13 additions & 0 deletions src/lib/__tests__/PreviewUI-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,19 @@ describe('lib/PreviewUI', () => {

ui.showNavigation('1', ['1', '2']);
});

it('should add a class if navigation is present', () => {
const { contentContainer } = ui;
ui.showNavigation('1', ['1']);
let isShowingNavigation = contentContainer.classList.contains(constants.CLASS_BOX_PREVIEW_HAS_NAVIGATION);
expect(isShowingNavigation).to.be.false;
ui.showNavigation('1', ['1', '2']);
isShowingNavigation = contentContainer.classList.contains(constants.CLASS_BOX_PREVIEW_HAS_NAVIGATION);
expect(isShowingNavigation).to.be.true;
ui.showNavigation('1', ['1']);
isShowingNavigation = contentContainer.classList.contains(constants.CLASS_BOX_PREVIEW_HAS_NAVIGATION);
expect(isShowingNavigation).to.be.false;
});
});

describe('showPrintButton()', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/_navigation.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$navigationBtnWidth: 50px;

.bp-is-fullscreen .bp-navigate {
display: none;
}
Expand All @@ -19,7 +21,7 @@
// Override default animations to only animate opacity since width animation to auto doesn't work
transition-property: opacity;
white-space: nowrap;
width: 50px;
width: $navigationBtnWidth;

&:hover {
opacity: 1;
Expand Down
1 change: 1 addition & 0 deletions src/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const CLASS_BOX_PREVIEW_BUTTON = 'bp-btn';
export const CLASS_BOX_PREVIEW_CONTAINER = 'bp-container';
export const CLASS_BOX_PREVIEW_FIND_BAR = 'bp-find-bar';
export const CLASS_BOX_PREVIEW_HAS_HEADER = 'bp-has-header';
export const CLASS_BOX_PREVIEW_HAS_NAVIGATION = 'bp-has-navigation';
export const CLASS_BOX_PREVIEW_HEADER = 'bp-header';
export const CLASS_BOX_PREVIEW_BASE_HEADER = 'bp-base-header';
export const CLASS_BOX_PREVIEW_HEADER_BTNS = 'bp-header-btns';
Expand Down
12 changes: 11 additions & 1 deletion src/lib/viewers/media/MP3.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
@import 'mediaBase';
@import '../../_navigation';

.bp-has-navigation {
.bp-media-mp3 {
.bp-media-container {
width: calc(100% - #{2 * $navigationBtnWidth}); // to prevent overlap in mobile devices
}
}
}

.bp-media-mp3 {
.bp-media-container {
height: 60px; // same as controls
max-width: 360px;
outline: 0 none;
overflow: visible; // to show settings popup
width: 360px;
width: 100%;
}

.bp-media-fullscreen-icon {
Expand Down

0 comments on commit a7ed4fc

Please sign in to comment.