add is-background-light class to slides/backgrounds that are > 128 brightness
This commit is contained in:
parent
8a50a46665
commit
20e72df4bf
1 changed files with 10 additions and 6 deletions
14
js/reveal.js
14
js/reveal.js
|
@ -714,8 +714,11 @@
|
|||
if( data.backgroundPosition ) element.style.backgroundPosition = data.backgroundPosition;
|
||||
if( data.backgroundTransition ) element.setAttribute( 'data-background-transition', data.backgroundTransition );
|
||||
|
||||
if( data.backgroundColor ) {
|
||||
|
||||
// If this slide has a background color, add a class that
|
||||
// signals if it is light
|
||||
if( element.style.backgroundColor && colorBrightness( element.style.backgroundColor ) > 128 ) {
|
||||
slide.classList.add( 'is-background-light' );
|
||||
element.classList.add( 'is-background-light' );
|
||||
}
|
||||
|
||||
container.appendChild( element );
|
||||
|
@ -1122,7 +1125,11 @@
|
|||
|
||||
if( typeof color === 'string' ) color = colorToRgb( color );
|
||||
|
||||
if( color ) {
|
||||
return ( color.r * 299 + color.g * 587 + color.b * 114 ) / 1000;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
@ -4100,9 +4107,6 @@
|
|||
addEventListeners: addEventListeners,
|
||||
removeEventListeners: removeEventListeners,
|
||||
|
||||
colorToRgb: colorToRgb,
|
||||
colorBrightness: colorBrightness,
|
||||
|
||||
// Facility for persisting and restoring the presentation state
|
||||
getState: getState,
|
||||
setState: setState,
|
||||
|
|
Loading…
Reference in a new issue