GithubHelp home page GithubHelp logo

slideshow's Introduction

Slideshow.js

一款超轻量级的 JavaScript 幻灯片创建框架,助你摆脱 PowerPoint 令人作呕的动画控制!

安装

bower install Slideshow.js

Showcase

https://idiotwu.me/got-to-fe/

兼容性

  • IE 10+
  • Chrome 23+
  • Firefox 21+
  • Safari 6+

基本用法

Slideshow.init( String:className [, Element: startContainer] )

初始化一个幻灯片,并返回一个由所有目标 class 的元素组成的 NodeTree 对象。

startContainer 指定了查找起点,默认为 document.body

注意:

  1. 第一帧动画会在初始化时被激活。
  2. 多次初始化幻灯片,只有最后一次的操作会被保留。

Slideshow.prev()

播放前一帧。

Slideshow.next()

播放下一帧。

Slideshow.jumpTo( String:indexChain )

跳转到指定帧,接受一个链式索引如 '1.2.3'

动画控制

  • 当动画帧被激活时,对应元素会被添加上 show 的 class,最顶层的元素只有在所有子项播放完成后 ,这个 class 才会被移除。

  • 被播放过的动画会被加上 played class,最顶层的元素只有在所有子项播放完成后,这个 class 才会被加上。

  • 因此可以借助 CSS3 Animation 来为对应的 class 状态添加动画。

事件监听

通过 Slideshow.addListener( Function: fn ) 可以为幻灯片的变换注册事件监听。通过 Slideshow.removeListener() 可以移除所有监听。

Slideshow.addListener 的回调函数接受三个参数:

  1. String:type:变换类型,值为 prev|next|jump
  2. Element:element:当前动作目标 DOM 元素
  3. Number:progress:幻灯片播放进度

同时回调函数内的 this 对象指向当前作用帧的 NodeTree 对象。

APIs

参见此处

Q&A

  1. Q: 为什么我只能创建一个幻灯片?
    A: 为什么你想要同时播放多个幻灯片?
  2. Q: 我 init 了以后怎么什么都没有发生?
    A: 没写样式。
  3. Q: 为什么要自己写动画?我不会!
    A: 出门左转 reveal.js

License

MIT.

slideshow's People

Contributors

idiotwu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ncou

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.