Browse Source

Merge pull request #3568 from bouzidanas/master

fix vertical stack background not working in scroll view
Hakim El Hattab 1 year ago
parent
commit
67b5ec1773
8 changed files with 24 additions and 11 deletions
  1. 2 2
      dist/reveal.css
  2. 2 2
      dist/reveal.esm.js
  3. 0 0
      dist/reveal.esm.js.map
  4. 2 2
      dist/reveal.js
  5. 0 0
      dist/reveal.js.map
  6. 15 3
      js/controllers/scrollview.js
  7. 1 0
      js/utils/constants.js
  8. 2 2
      package-lock.json

File diff suppressed because it is too large
+ 2 - 2
dist/reveal.css


File diff suppressed because it is too large
+ 2 - 2
dist/reveal.esm.js


File diff suppressed because it is too large
+ 0 - 0
dist/reveal.esm.js.map


File diff suppressed because it is too large
+ 2 - 2
dist/reveal.js


File diff suppressed because it is too large
+ 0 - 0
dist/reveal.js.map


+ 15 - 3
js/controllers/scrollview.js

@@ -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;
@@ -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' );
 
@@ -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;
 				}
 

+ 1 - 0
js/utils/constants.js

@@ -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/;

+ 2 - 2
package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "reveal.js",
-  "version": "5.0.2",
+  "version": "5.0.4",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "reveal.js",
-      "version": "5.0.2",
+      "version": "5.0.4",
       "license": "MIT",
       "devDependencies": {
         "@babel/core": "^7.23.2",

Some files were not shown because too many files changed in this diff