aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2014-09-10 10:12:25 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2014-09-10 10:12:25 +0200
commit41f20301b6a634003ed89f222f5fe1995ca29ce5 (patch)
treee3db03890e1252a9078fdf1c6493b7624441d1f4 /js
parentbc2974fef879a273fa5600b9b2e7d1481ebe8afd (diff)
downloadfosdem-2018-presentation-41f20301b6a634003ed89f222f5fe1995ca29ce5.tar
fosdem-2018-presentation-41f20301b6a634003ed89f222f5fe1995ca29ce5.tar.gz
has-dark-background
Diffstat (limited to 'js')
-rw-r--r--js/reveal.js30
1 files changed, 20 insertions, 10 deletions
diff --git a/js/reveal.js b/js/reveal.js
index 81c100c..7cc551c 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -717,10 +717,16 @@
container.appendChild( element );
// If this slide has a background color, add a class that
- // signals if it is light
+ // signals if it is light or dark. If the slide has no background
+ // color, no class will be set
var computedBackgroundColor = window.getComputedStyle( element ).backgroundColor;
- if( computedBackgroundColor && colorBrightness( computedBackgroundColor ) > 128 ) {
- slide.classList.add( 'has-light-background' );
+ if( computedBackgroundColor ) {
+ if( colorBrightness( computedBackgroundColor ) < 128 ) {
+ slide.classList.add( 'has-dark-background' );
+ }
+ else {
+ slide.classList.add( 'has-light-background' );
+ }
}
return element;
@@ -2463,13 +2469,17 @@
}
- // If the slide has a light background, bubble that up as a
- // class to .reveal container
- if( currentSlide && currentSlide.classList.contains( 'has-light-background' ) ) {
- dom.wrapper.classList.add( 'has-light-background' );
- }
- else {
- dom.wrapper.classList.remove( 'has-light-background' );
+ // If there's a background brightness flag for this slide,
+ // bubble it to the .reveal container
+ if( currentSlide ) {
+ [ 'has-light-background', 'has-dark-background' ].forEach( function( classToBubble ) {
+ if( currentSlide.classList.contains( classToBubble ) ) {
+ dom.wrapper.classList.add( classToBubble );
+ }
+ else {
+ dom.wrapper.classList.remove( classToBubble );
+ }
+ } );
}
// Allow the first background to apply without transition