How does reveal.js resize elements?

前端 未结 4 855
[愿得一人]
[愿得一人] 2021-02-02 17:22

I am trying to understand how reveal.js resizes elements dynamically.

To see this, adjust the height of the page and see how elements (to a certain degree) shrink as the

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-02 17:58

    If you look at the source code hosted on github https://github.com/hakimel/reveal.js/blob/master/js/reveal.js you can see exactly what it's doing.

    It checks for browser CSS features like 2d and 3d transforms

        // Detect support for CSS 3D transforms
    supports3DTransforms = 'WebkitPerspective' in document.body.style ||
    'MozPerspective' in document.body.style ||
    'msPerspective' in document.body.style ||
    'OPerspective' in document.body.style ||
    'perspective' in document.body.style
    

    It uses basic event listeners

        // Force a layout when the whole page, incl fonts, has loaded
    window.addEventListener( 'load', layout, false );
    ...
    /**
    * Binds all event listeners.
    */
    function addEventListeners() {
    
    window.addEventListener( 'hashchange', onWindowHashChange, false );
    window.addEventListener( 'resize', onWindowResize, false );
    ...
    

    The source code actually has decent commenting so you should be able to learn quite a bit.

提交回复
热议问题