소스 검색

fit-text helper now triggers lazyily when slide enters view distance

Hakim El Hattab 5 년 전
부모
커밋
aa6677911c
6개의 변경된 파일21개의 추가작업 그리고 11개의 파일을 삭제
  1. 6 0
      css/layout.scss
  2. 0 0
      dist/reveal.css
  3. 0 0
      dist/reveal.esm.js
  4. 0 0
      dist/reveal.js
  5. 15 0
      js/controllers/slidecontent.js
  6. 0 11
      js/reveal.js

+ 6 - 0
css/layout.scss

@@ -16,6 +16,12 @@
 	box-sizing: border-box;
 	box-sizing: border-box;
 }
 }
 
 
+// Text that auto-fits it's container
+.reveal .r-fit-text {
+	display: inline-block; // https://github.com/rikschennink/fitty#performance
+	white-space: nowrap;
+}
+
 // Stack multiple elements on top of each other
 // Stack multiple elements on top of each other
 .reveal .r-stack {
 .reveal .r-stack {
 	display: grid;
 	display: grid;

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/reveal.css


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/reveal.esm.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/reveal.js


+ 15 - 0
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 { extend, queryAll, closest } from '../utils/util.js'
 import { isMobile } from '../utils/device.js'
 import { isMobile } from '../utils/device.js'
 
 
+import fitty from 'fitty';
+
 /**
 /**
  * Handles loading, unloading and playback of slide
  * Handles loading, unloading and playback of slide
  * content such as images, videos and iframes.
  * 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
+			} );
+		} );
+
 	}
 	}
 
 
 	/**
 	/**

+ 0 - 11
js/reveal.js

@@ -25,8 +25,6 @@ import {
 	POST_MESSAGE_METHOD_BLACKLIST
 	POST_MESSAGE_METHOD_BLACKLIST
 } from './utils/constants.js'
 } from './utils/constants.js'
 
 
-import fitty from 'fitty';
-
 // The reveal.js version
 // The reveal.js version
 export const VERSION = '4.0.2';
 export const VERSION = '4.0.2';
 
 
@@ -283,15 +281,6 @@ export default function( revealElement, options ) {
 		dom.statusElement = createStatusElement();
 		dom.statusElement = createStatusElement();
 
 
 		dom.wrapper.setAttribute( 'role', 'application' );
 		dom.wrapper.setAttribute( 'role', 'application' );
-
-		// The r-fit-text helper resizes text to be as large as
-		// possible within its given container
-		fitty( '.r-fit-text', {
-			minSize: 24,
-			maxSize: config.height * 0.8,
-			observeMutations: false,
-			observeWindow: false
-		} );
 	}
 	}
 
 
 	/**
 	/**

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.