In Development, Html, Tools by |

In this article, I will show an example of how to use the impress.js library to make a presentation in Javascript.

The library leaves plenty of flexibility to the user.

If you have nothing to present, the library will not help you. You should have an idea in mind, put it on paper, design the slides in HTML and CSS, and the use this library to put things together, keeping in mind that the transitions between slides are automatically handled, depending on the relative position between the two slides.

Once your idea is on paper, you can place your slides and style them.

On each div, you set the data-x, data-y, data-z attributes, place your slide on the 3d canvas. The rotation of each slide can be defined by setting the data-rotate-x, data-rotate-y and data-rotate-z like shown below:

Slide 1: This slide defines no rotation or positioning

Slide 2: This one defines a shift of 1500 pixels to the right (data-x) and a rotation of 180 degrees with relation to the x  axis. The data scale also changes from 2 to 4.

Slide 3: This slide is place 1500 in the negative axis, giving the impression of being further away.

Slide 4: Here the slider goes back to the original rotation and shifts to the left

 Slides 5, 6 and 7: These 3 slides are positioned 45 degrees from each other, around the x axis. This create a cool rotation effect:

 Slides 8, 9 and 10: End of the presentation.

You can style your slides using CSS. In this example, there are some common things to all slides (with the step class)

DIV attributes that you can set:

  •     data-x- Places the slide on the x-axis
  •     data-y- Places the slide on the y-axis
  •     data-z- Places the slide on the z-axis
  •     data-scale- Scales your slides in respect to the other slides. Example: If current scale value is 1, data-scale=’4′ will scale the slide 4 times bigger than other slides and data-scale=’-4′ will reduce the scale of the slide to 4 times smaller.
  •     data-rotate-x Rotates the slide around the x-axis by a given number degrees.
  •     data-rotate-y Rotates the slide around the y-axis by a given number degrees.
  •     data-rotate-z Rotates the slide around the z-axis by a given number degrees.

The impress.js library will workout the transition to the next slide, depending on the relative position.

Take a look at it and have fun!

 

Demo

Download

 

Images on the demo and article downloaded from Shutterstock: introduction image group portrait cat cat on tree cat and dog computer

I'm a software developer interested in mostly web application development and Java. During the last few years I've developed an interest in the Grails framework as well as in JQuery.