Ver código fonte

only carry forward fragment visibiltiy if style remains unchanged

Hakim El Hattab 5 anos atrás
pai
commit
34ab7ded55
3 arquivos alterados com 16 adições e 3 exclusões
  1. 0 0
      dist/reveal.min.js
  2. 12 2
      js/controllers/autoanimate.js
  3. 4 1
      js/utils/constants.js

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
dist/reveal.min.js


+ 12 - 2
js/controllers/autoanimate.js

@@ -1,4 +1,5 @@
 import { queryAll, extend, createStyleSheet } from '../utils/util.js'
+import { FRAGMENT_STYLE_REGEX } from '../utils/constants.js'
 
 /**
  * Automatically animates matching elements across
@@ -168,8 +169,17 @@ export default class AutoAnimate {
 			// conflicts with fragment animations
 			delete toProps.styles['opacity'];
 
-			if( from.classList.contains( 'fragment' ) && animationOptions.slideDirection === 'forward' ) {
-				to.classList.add( 'visible', 'disabled' );
+			if( from.classList.contains( 'fragment' ) ) {
+
+				let fromFragmentStyle = ( from.className.match( FRAGMENT_STYLE_REGEX ) || [''] )[0];
+				let toFragmentStyle = ( to.className.match( FRAGMENT_STYLE_REGEX ) || [''] )[0];
+
+				// Only skip the fragment if the fragment animation style
+				// remains unchanged
+				if( fromFragmentStyle === toFragmentStyle && animationOptions.slideDirection === 'forward' ) {
+					to.classList.add( 'visible', 'disabled' );
+				}
+
 			}
 
 		}

+ 4 - 1
js/utils/constants.js

@@ -4,4 +4,7 @@ export const HORIZONTAL_SLIDES_SELECTOR = '.slides>section';
 export const VERTICAL_SLIDES_SELECTOR = '.slides>section.present>section';
 
 // Methods that may not be invoked via the postMessage API
-export const POST_MESSAGE_METHOD_BLACKLIST = /registerPlugin|registerKeyboardShortcut|addKeyBinding|addEventListener/;
+export const POST_MESSAGE_METHOD_BLACKLIST = /registerPlugin|registerKeyboardShortcut|addKeyBinding|addEventListener/;
+
+// Regex for retrieving the fragment style from a class attribute
+export const FRAGMENT_STYLE_REGEX = /fade-(down|up|right|left|out|in-then-out|in-then-semi-out)|semi-fade-out|current-visible|shrink|grow/;

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff