超强的制作PPT的impress.js

在查看网页时,忽然发现了Impress.js 很强大,很简单的制作PPT的js.

附件是demo

以下是 对官方文档的关键点的中英文翻译

<!--[if gte mso 9]><xml><w:WordDocument><w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel><w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery><w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery><w:DocumentKind>DocumentNotSpecified</w:DocumentKind><w:DrawingGridVerticalSpacing>7.8</w:DrawingGridVerticalSpacing><w:View>Normal</w:View><w:Compatibility></w:Compatibility><w:Zoom>0</w:Zoom></w:WordDocument></xml><![endif]-->

How To Use Impress.Js

如何使用Impress.js

Posted on January 4, 2012

发表于20120104

Yesterday, I wrote about Impress.js, an awesome JavaScript library for creating online presentations. Since posting online, I’ve had several people ask how exactly to use it, as there’s no set documentation on the actual project page.  This guide will help you get started and allow you to create a simple slideshow, but after completing it please bear in mind that there’s so much more that can be done with it.  The only limit is your creativity!

昨天,我写了一个相当棒用于在线演示的javascript类库--Impress.js。因为在实际的项目页面也没有一套文档,我发帖以 来,有很多人问到底怎么使用。这个指南将帮助你开始创建一个简单的幻灯片。完成之后,请您也记住:它还可以做很多。唯一限制你的是你的创造力。

This tutorial is available for you to view and download on GitHub

Requirements(要求)

To see this tutorial in action, please use Google Chrome or Safari (or Firefox 10 or IE10).  Impress.js is not currently compatible with earlier versions of Firefox or Internet Explorer.

要看到这个文章的效果,请使用Google ChromeSafari(Firefox10 IE10)Impress.jsfirefoxie的早起版本将不能完全显示的.
--因为用到了HTML5+CSS3

 

Setup安装

The first thing you want to do is create a new webpage.  Mine’s index.html and within it setup the basic head and body elements.

你要做的第一件事就是建一个网页。以下是我的页面index.html基本的headbody元素。

<!doctype html>

<html>

    <head>

        <title>Impress Tutorial</title>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    </head>

    <body>

    </body>

</html>

Add the impress.js file before the end of the body element.  This imports the Impress library into your project

body元素结束前增加impress.js文件来将Impress类库导入到你的项目中

<script type="text/javascript" src="impress.js"></script>

Next we’ll create a wrapper which will contain the slideshow.  This is simply a <div> element with an id of ‘impress’

接下来,我们将创建一个包装器来包含幻灯片。这是一个简单的id=impressdiv元素

<div id="impress"></div>

Creating Slides创建幻灯片

Now you’ll see how easy it is to create a new slide in the presentation.  Each slide is a <div> element (within the wrapper) with a class name of ‘step’

现在,你将发现在演示文稿中创建一个幻灯片是多么容易。每个幻灯片都是一个带有step类名的div元素

<div class="step">

    My first slide

</div>

Whilst that creates a simple slide, things are a lot more fun you start adding data properties to your slides.  Data attributes signify properties of your slide for when it’s NOT the active slide.  The following data properties are available to you:
虽然那创建了一个简单的幻灯片,但在你的幻灯片中增加数据属性也是非常有趣的。Data属性标注了当幻灯片不是活动幻灯片是的信息。以下数据为:

· data-x = the x co-ordinate of the slide 幻灯片的x坐标

· data-y = the y co-ordinate of the slide 幻灯片的y坐标

· data-z = the z co-ordinate of the slide (how far/close it appears to the user)幻灯片的z坐标

· data-scale = scales your slide by a factor of this value.  A data-scale of 5 would be 5 times the original size of your slide 缩放幻灯片的因素

· data-rotate = rotates your slide by the specified number of degrees 通过指定的度数旋转你的幻灯片

· data-rotate-x = For 3D slides.  This is the number of degrees it should be rotated about the x-axis.  (Tilt forward/lean back)

· data-rotate-y = For 3D slides. This is the number of degrees it should be rotated about the y-axis (swing in from the left/right)

· data-rotate-z = For 3D slides. This is the number of degrees it should be rotated about the z-axis

 

Data Attributes In Action

The following slide configuration will guide you through each of the data attributes in action.

Let’s start with an initial slide.  This slide has it’s x and y data attributes set to 0, so will appear in the center of the page.

<div class="step" data-x="0" data-y="0">

    This is my first slide

</div>

The second slide will have an x position of 500, but the y position of 0.  This means that it’s going to have to come in 500 pixels across the x-axis (slide left) when it becomes active.

<div class="step" data-x="500" data-y="0">

    This is slide 2

</div>

Easy huh?  The next slide will start with the same x-position as slide 2, but a y position of –400.  This will slide in from the top 400 pixels.

<div class="step" data-x="500" data-y="-400">

    This is slide 3

</div>

Slide 4 uses the scale value to show how a slide can appear to zoom in/out.  It has a scale value of 0.5, meaning that it’s half the size it should be.  When it becomes active the presentation will adjust the scale of ALL the slides by the factor required to make the scale of the active website 1.  What this means in this example is that for this slide to display normally (scale value 1) it will need to be scaled up by a factor of 2 (0.5*2 = 1).  All the other slides will also be scaled up by a factor of two, and become twice the size.

<div class="step" data-x="500" data-y="-800" data-scale="0.5">

    This is slide 4

</div>

The rotate attributes allows you to rotate a slide into view.  Slide 5 is set to rotate by 90 degrees.

<div class="step" data-x="0" data-y="-800" data-rotate="90">

    This is slide 5 and it rotates in.

</div>

Finally, for a 3D transition, you can specify rotate attributes for each dimensional axis (x,y,z).

The x axis is the horizontal axis.  This means that you can make things tilt forwards (positive value) or backwards (negative value).
The y axis is the vertical axis so you can have things swing in from the left (negative value) or right (positive value).
The z axis is the depth axis (the one coming out at you) so rotating things on this would be rotating things up (negative value) and down (positive value).

Combinations

Now that you know all about the data attributes, which is really all you need to animate your slideshow, you can use your imagination to combine these in weird and wonderful ways to create your own style of slideshow.

<div class="step" data-x="-2600" data-y="-800" data-rotate-x="30" data-rotate-y="-60" data-rotate-z="90" data-scale="4">

    This is slide 7 and it has a 3D transition AND a scale.

</div>

Unsupported Browsers

Impress automatically detects whether or not a browser supports it or not, and if it doesn’t then automatically adds a class name called ‘impress-not-supported’ to the wrapper ‘<div>’.  Using some CSS we can show a message to people on browsers which aren’t supported by Impress.

At the start of your <div id=”impress”> add the following:

<div class="no-support-message">

    Your browser doesn't support impress.js.  Try Chrome or Safari.

</div>

Then, create a stylesheet or add this to your existing stylesheet:

.no-support-message { display:none; }

.impress-not-supported .no-support-message { display:block; }

This hides the message by default, but then displays it to browser if the impress-not-supported class is present.

Have fun!

This tutorial covers the fundamentals of using Impress.js to create your very own online presentation.  The entire example is available on Github for you to download and play with.

- See more at: http://www.cubewebsites.com/blog/guides/how-to-use-impress-js/#sthash.eYP2BTAi.dpuf

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值