aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2020-05-26 09:46:50 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2020-05-26 09:47:01 +0200
commite6244a57b549ad788d02596c98ff33f6c348899e (patch)
tree6717fff3b4d6ad5f286d707b3cc64e59d7836419 /js
parentb074050a6d4dd7beaf115805859af40f7a25e6db (diff)
downloadfosdem-2021-minimalism-presentation-e6244a57b549ad788d02596c98ff33f6c348899e.tar
fosdem-2021-minimalism-presentation-e6244a57b549ad788d02596c98ff33f6c348899e.tar.gz
fix polyfills, add ie11 support
Diffstat (limited to 'js')
-rw-r--r--js/controllers/autoanimate.js6
-rw-r--r--js/reveal.js5
-rw-r--r--js/utils/util.js28
3 files changed, 29 insertions, 10 deletions
diff --git a/js/controllers/autoanimate.js b/js/controllers/autoanimate.js
index ee4928c..01711a2 100644
--- a/js/controllers/autoanimate.js
+++ b/js/controllers/autoanimate.js
@@ -1,4 +1,4 @@
-import { queryAll, extend, createStyleSheet } from '../utils/util.js'
+import { queryAll, extend, createStyleSheet, matchesSelector } from '../utils/util.js'
import { FRAGMENT_STYLE_REGEX } from '../utils/constants.js'
// Counter used to generate unique IDs for auto-animated elements
@@ -463,11 +463,11 @@ export default class AutoAnimate {
// Disable scale transformations on text nodes, we transiition
// each individual text property instead
- if( pair.from.matches( textNodes ) ) {
+ if( matchesSelector( pair.from, textNodes ) ) {
pair.options = { scale: false };
}
// Animate individual lines of code
- else if( pair.from.matches( codeNodes ) ) {
+ else if( matchesSelector( pair.from, codeNodes ) ) {
// Transition the code block's width and height instead of scaling
// to prevent its content from being squished
diff --git a/js/reveal.js b/js/reveal.js
index 593b184..7c3c7f9 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -1489,7 +1489,10 @@ export default function( revealElement, options ) {
let reverse = config.rtl && !isVerticalSlide( element );
- element.classList.remove( 'past', 'present', 'future' );
+ // Avoid .remove() with multiple args for IE11 support
+ element.classList.remove( 'past' );
+ element.classList.remove( 'present' );
+ element.classList.remove( 'future' );
// http://www.w3.org/html/wg/drafts/html/master/editing.html#the-hidden-attribute
element.setAttribute( 'hidden', '' );
diff --git a/js/utils/util.js b/js/utils/util.js
index b3ffc73..392ca72 100644
--- a/js/utils/util.js
+++ b/js/utils/util.js
@@ -86,6 +86,27 @@ export const transformElement = ( element, transform ) => {
}
/**
+ * Element.matches with IE support.
+ *
+ * @param {HTMLElement} target The element to match
+ * @param {String} selector The CSS selector to match
+ * the element against
+ *
+ * @return {Boolean}
+ */
+export const matchesSelector = ( target, selector ) => {
+
+ // There's some overhead doing this each time, we don't
+ // want to rewrite the element prototype but should still
+ // be enough to feature detect once at startup...
+ let matchesMethod = parent.matches || parent.matchesSelector || parent.msMatchesSelector;
+
+ // If we find a match, we're all set
+ return !!( matchesMethod && matchesMethod.call( target, selector ) );
+
+}
+
+/**
* Find the closest parent that matches the given
* selector.
*
@@ -102,13 +123,8 @@ export const closestParent = ( target, selector ) => {
while( parent ) {
- // There's some overhead doing this each time, we don't
- // want to rewrite the element prototype but should still
- // be enough to feature detect once at startup...
- let matchesMethod = parent.matches || parent.matchesSelector || parent.msMatchesSelector;
-
// If we find a match, we're all set
- if( matchesMethod && matchesMethod.call( parent, selector ) ) {
+ if( matchesSelector( parent, selector ) ) {
return parent;
}