Skip to content

Commit

Permalink
Merge pull request #3568 from bouzidanas/master
Browse files Browse the repository at this point in the history
fix vertical stack background not working in scroll view
  • Loading branch information
hakimel authored Feb 5, 2024
2 parents 16f6633 + 50580c3 commit 67b5ec1
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 15 deletions.
4 changes: 2 additions & 2 deletions dist/reveal.css

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/reveal.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.esm.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/reveal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js.map

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions js/controllers/scrollview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HORIZONTAL_SLIDES_SELECTOR } from '../utils/constants.js'
import { HORIZONTAL_SLIDES_SELECTOR, SLIDES_BACKGROUNDS_SELECTOR } from '../utils/constants.js'
import { queryAll } from '../utils/util.js'

const HIDE_SCROLLBAR_TIMEOUT = 500;
Expand Down Expand Up @@ -40,6 +40,7 @@ export default class ScrollView {
this.slideHTMLBeforeActivation = this.Reveal.getSlidesElement().innerHTML;

const horizontalSlides = queryAll( this.Reveal.getRevealElement(), HORIZONTAL_SLIDES_SELECTOR );
const slideBackgrounds = queryAll( this.Reveal.getRevealElement(), SLIDES_BACKGROUNDS_SELECTOR );

this.viewportElement.classList.add( 'loading-scroll-mode', 'reveal-scroll' );

Expand Down Expand Up @@ -76,8 +77,19 @@ export default class ScrollView {
page.className = 'scroll-page';
pageElements.push( page );

// Copy the presentation-wide background to each page
if( presentationBackground ) {
// This transfers over the background of the vertical stack containing
// the slide if it exists. Otherwise, it uses the presentation-wide
// background.
if( slideBackgrounds && slideBackgrounds.length > h ) {
const slideBackground = slideBackgrounds[h];
const pageBackground = window.getComputedStyle( slideBackground );

if( pageBackground && pageBackground.background ) {
page.style.background = pageBackground.background;
} else if( presentationBackground ) {
page.style.background = presentationBackground;
}
} else if( presentationBackground ) {
page.style.background = presentationBackground;
}

Expand Down
1 change: 1 addition & 0 deletions js/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
export const SLIDES_SELECTOR = '.slides section';
export const HORIZONTAL_SLIDES_SELECTOR = '.slides>section';
export const VERTICAL_SLIDES_SELECTOR = '.slides>section.present>section';
export const SLIDES_BACKGROUNDS_SELECTOR = '.backgrounds>.slide-background';

// Methods that may not be invoked via the postMessage API
export const POST_MESSAGE_METHOD_BLACKLIST = /registerPlugin|registerKeyboardShortcut|addKeyBinding|addEventListener|showPreview/;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 67b5ec1

Please sign in to comment.