aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/slidecontent.js
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2020-06-09 10:28:01 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2020-06-09 10:28:01 +0200
commitaa6677911ca0a417aa445149349f8ffbf2ca5c2e (patch)
treee1347dd6acfc74b1c1c74c6c4c3c91b0172f3b41 /js/controllers/slidecontent.js
parentf231c53b9cc9062b51b8a9a3b4a6a9c19cc25b0b (diff)
downloadfosdem-2021-minimalism-presentation-aa6677911ca0a417aa445149349f8ffbf2ca5c2e.tar
fosdem-2021-minimalism-presentation-aa6677911ca0a417aa445149349f8ffbf2ca5c2e.tar.gz
fit-text helper now triggers lazyily when slide enters view distance
Diffstat (limited to 'js/controllers/slidecontent.js')
-rw-r--r--js/controllers/slidecontent.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/js/controllers/slidecontent.js b/js/controllers/slidecontent.js
index 7ed5573..485a2ce 100644
--- a/js/controllers/slidecontent.js
+++ b/js/controllers/slidecontent.js
@@ -2,6 +2,8 @@ import { HORIZONTAL_SLIDES_SELECTOR, VERTICAL_SLIDES_SELECTOR } from '../utils/c
import { extend, queryAll, closest } from '../utils/util.js'
import { isMobile } from '../utils/device.js'
+import fitty from 'fitty';
+
/**
* Handles loading, unloading and playback of slide
* content such as images, videos and iframes.
@@ -159,6 +161,19 @@ export default class SlideContent {
}
+ // Autosize text with the r-fit-text class based on the
+ // size of its container. This needs to happen after the
+ // slide is visible in order to measure the text.
+ Array.from( document.querySelectorAll( '.r-fit-text:not([data-fitted])' ) ).forEach( element => {
+ element.dataset.fitted = '';
+ fitty( element, {
+ minSize: 24,
+ maxSize: this.Reveal.getConfig().height * 0.8,
+ observeMutations: false,
+ observeWindow: false
+ } );
+ } );
+
}
/**