hakimel / reveal.js

The HTML Presentation Framework
https://revealjs.com
MIT License
67.33k stars 16.59k forks source link

Disable auto layout on a per-slide basis #2719

Open multimeric opened 4 years ago

multimeric commented 4 years ago

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">.

pykong commented 3 years ago

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:

OperationalFallacy commented 2 years ago

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.

einarpersson commented 1 year ago

I am using Svelte and stumbled into this as well.

jkub6 commented 5 months ago

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