开发者

Google IO Slides Template - Javascript on each slide

开发者 https://www.devze.com 2023-03-05 17:46 出处:网络
this my first question! I am playing around with the Google slide template that was used for the Google IO presentations this year (2011).

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 fram开发者_StackOverflow中文版ework? Thanks a ton!


In the slide definition, you can include code.

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


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号