浏览代码

fix auto-animate bug on centered slides

Hakim El Hattab 5 年之前
父节点
当前提交
3a032a836a
共有 4 个文件被更改,包括 20 次插入14 次删除
  1. 0 0
      dist/reveal.esm.js
  2. 0 0
      dist/reveal.js
  3. 3 2
      examples/auto-animate.html
  4. 17 12
      js/controllers/autoanimate.js

文件差异内容过多而无法显示
+ 0 - 0
dist/reveal.esm.js


文件差异内容过多而无法显示
+ 0 - 0
dist/reveal.js


+ 3 - 2
examples/auto-animate.html

@@ -162,12 +162,13 @@
 
 		</div>
 
-		<script src="../dist/reveal.es5.js"></script>
+		<script src="../dist/reveal.js"></script>
 		<script src="../dist/plugin/highlight.js"></script>
 		<script>
 			Reveal.initialize({
 				center: true,
-				hash: true
+				hash: true,
+				plugins: [ RevealHighlight ]
 			});
 		</script>
 

+ 17 - 12
js/controllers/autoanimate.js

@@ -331,6 +331,8 @@ export default class AutoAnimate {
 	 */
 	getAutoAnimatableProperties( direction, element, elementOptions ) {
 
+		let config = this.Reveal.getConfig();
+
 		let properties = { styles: [] };
 
 		// Position and size
@@ -343,17 +345,20 @@ export default class AutoAnimate {
 				bounds = elementOptions.measure( element );
 			}
 			else {
-				let scale = this.Reveal.getScale();
-				bounds = {
-					x: element.offsetLeft * scale,
-					y: element.offsetTop * scale,
-					width: element.offsetWidth * scale,
-					height: element.offsetHeight * scale
-				};
-
-				// More precise, but breaks when used in combination
-				// with zoom for scaling the deck ¯\_(ツ)_/¯
-				// bounds = element.getBoundingClientRect();
+				if( config.center ) {
+					// More precise, but breaks when used in combination
+					// with zoom for scaling the deck ¯\_(ツ)_/¯
+					bounds = element.getBoundingClientRect();
+				}
+				else {
+					let scale = this.Reveal.getScale();
+					bounds = {
+						x: element.offsetLeft * scale,
+						y: element.offsetTop * scale,
+						width: element.offsetWidth * scale,
+						height: element.offsetHeight * scale
+					};
+				}
 			}
 
 			properties.x = bounds.x;
@@ -365,7 +370,7 @@ export default class AutoAnimate {
 		const computedStyles = getComputedStyle( element );
 
 		// CSS styles
-		( elementOptions.styles || this.Reveal.getConfig().autoAnimateStyles ).forEach( style => {
+		( elementOptions.styles || config.autoAnimateStyles ).forEach( style => {
 			let value;
 
 			// `style` is either the property name directly, or an object

部分文件因为文件数量过多而无法显示