Mybbor
Mybbor

Reputation: 163

Google IO Slides Template - Javascript on each slide

this my first question! I am playing around with the Google slide template that was used for the Google IO presentations this year (2011).

http://code.google.com/p/io-2011-slides/

What I would like to do is run Javascript on a per slide basis. This is code from another SlideShow library that I would like to recreate using the Google IO template:

//You can trigger Javascript based on the slide number like this:
$('html').bind('slide', function(e, id) { 
  switch(id) {
    case 2:
      console.log('This is the second slide.');;
      break;
    case 3:
      console.log('Hello, third slide.');
      break;
  }
});

Can anyone suggest a way to do something similar with the Google IO slide framework? Thanks a ton!

Upvotes: 2

Views: 2260

Answers (2)

Detect
Detect

Reputation: 2069

Looking at the slides code, I noticed that it emits events slideenter and slideleave. So Bemmu's solution should work. You might also be able to do article.addEventListener('slideenter', function(){...}, false) or (.attachEvent for IE)

Upvotes: 0

Bemmu
Bemmu

Reputation: 18217

In the slide definition, you can include code.

<article onslideenter="console.log('This is the second slide.');">
...

Upvotes: 2

Related Questions