reveal.js icon indicating copy to clipboard operation
reveal.js copied to clipboard

Disable auto layout on a per-slide basis

Open multimeric opened this issue 5 years ago • 5 comments

Slide content is centred using JS, which can be disabled for the entire presentation, as is described here.

Since this is done dynamically, is there a way to disable this behaviour on a per-slide basis? If not, is it possible to get a class for <section> elements (slides) that disables this ? For example <section class="reveal-nocenter">.

multimeric avatar Jul 04 '20 07:07 multimeric

A per-slide deactivation of the layout via Reveal.configure does not work as of reveal.js 4.1, either with the disableLayout or centering option:

<section id="my-slide" class="disable-layout">
 content....
</section>
Reveal.on('slidechanged', event => {
  let currentSlide = event.currentSlide;
  let disableLayout = currentSlide.classList.contains("disable-layout");
  Reveal.configure({ disableLayout: disableLayout });
  console.log('disable-layout: ', disableLayout);
  Reveal.sync();
  Reveal.layout();
});

Calling Reveal.sync() and/or Reveal.layout() after Reveal.configure() does not help either. Also, using an instance like let deck = new Reveal({...}) seems to change the layout on a per-slide basis it does not work consistently, as it appears it introduces many defects into my presentation, i.e. it does not produce the same layout as initializing with disabled layout.

In lieu of the feature requested, the potential workarounds are:

  1. Initialize with disableLayout: true and reimplement centering and layout via your own CSS as you require.
  2. Outsource individual files to an iframe. (See: https://revealjs.com/backgrounds/#iframe-backgrounds)
  3. Can we overwrite the layouting behavior? I am not sure what it would take. Investigating... No success.

See:

  • https://revealjs.com/presentation-size/
  • https://revealjs.com/api/#misc

pykong avatar Mar 21 '21 17:03 pykong

I've also run into this. I'm using reveal inside React. The best solution would be rendering individual slides with a Slide component. It could accept props and do whatever users need, or they could extend it to implement own rendering.

The section is a primitive component in react terms, but it is very limited what it can do.

OperationalFallacy avatar Jan 14 '22 16:01 OperationalFallacy

I am using Svelte and stumbled into this as well.

einarpersson avatar Jun 20 '23 15:06 einarpersson

This would be a very useful feature for me also. I am using Quarto.

jkub6 avatar Jan 29 '24 04:01 jkub6