0

I tried to get the count of all slides and change to one of them using plain javascript. I'm not into react and wasn't able to find a global object to call some functions on.

Is there something like: presentation.loadSlide(2); ?

Ronen Ness
  • 9,923
  • 4
  • 33
  • 50
Cracker0dks
  • 2,422
  • 1
  • 24
  • 39
  • If everything fails: `window.location = "#/2?presenter" ` – Jonas Wilms Nov 15 '17 at 18:26
  • yeah thanks I thought this as well, but I dont know how to get the count of all slides and get an error if I load a slide out of bounds (would be a workaround if it would load the last slide on a very high number out of bounds) – Cracker0dks Nov 15 '17 at 19:06
  • do you have any control over the React project. Or, it is someone else's project and you cannot modify React code. – Vipin Kumar Nov 23 '17 at 12:39
  • I have control yes. Is there is no other way around? – Cracker0dks Nov 23 '17 at 14:42
  • Ok, then if you have control over React then I guess you already have slides count but want it in global object, so that you can access it via `window.slidesCount` – Vipin Kumar Nov 23 '17 at 15:33

2 Answers2

3

Please add a reference to your Deck component like below

<Deck ref={(deck) => {this.deck = deck; }} transition={["zoom", "slide"]} transitionDuration={500} theme={theme}>
  ...
</Deck>

Now you have a property by the name of deck in your component. Use componentDidMount lifecycle method to retrieve this.deck.props.children.length and assign it to window.slideCount.

componentDidMount() {
  window.slideCount = this.deck.props.children.length
}

Now open browser console and type slideCount, you will se you have slide count displayed there. After that you can use following to change the slides

window.location = "#/1"
Vipin Kumar
  • 6,441
  • 1
  • 19
  • 25
0

From the docs,

The GoToAction tag lets you jump to another slide in your deck. The GoToAction can be used a simple button that supports Base styling or accept a render prop with a callback to support custom components

The following code will render a button that will jump to a specific slide in your deck.

<GoToAction slide={3}>Jump to 3</GoToAction>
palsrealm
  • 5,083
  • 1
  • 20
  • 25
  • thanks. But I need to control the presentation from outside an iFrame (Jump to next,prev, first, last slide...), so this don't help me mutch. – Cracker0dks Nov 20 '17 at 09:45