A declarative approach for HTML Timing using SMIL Timesheets
A simple use case is to define an HTML rotating banner. Here’s an example, blatantly stolen from PortableLinuxApps.org but described with pure SMIL attributes:
CSS transition: | | | | |
You’ll have to load our timesheet
scheduler by adding this in the <head>
section:
<script type="text/javascript" src="timesheets.js"></script>
The rotating banner itself is described as follows:
<div id="banner" smil:timeContainer="seq" smil:repeatCount="indefinite"> <img smil:dur="3s" src="images/dosbox.png" alt="relive the good old days"/> <img smil:dur="3s" src="images/gnote.png" alt="100% free software, 0% hassle"/> <img smil:dur="3s" src="images/gpodder.png" alt="simple, usable podcast consumption"/> <img smil:dur="3s" src="images/transmission.png" alt="a fast, easy and free BitTorrent client"/> </div>
"indefinite"
: run continuously) More information about time containers can be found in the timeContainer page.
By default, our Timesheet scheduler
will show each image by setting its smil
attribute to
"active"
.
This allows to add CSS transitions, like the cross-fade effect in the
above example — that is, if your browser supports it (Firefox 4+,
Safari 4+, Opera 10.6+).
#banner img { position: absolute; top: 0; transition : all 2s; -o-transition : all 2s; -moz-transition : all 2s; -webkit-transition : all 2s; opacity: 0; } #banner img[smil=active] { opacity: 1; }
Other ways to show/hide child elements of a time container are described in the timeAction page.
All roads lead to Rome… our Timesheet Scheduler supports several markup variants for SMIL Timing and SMIL Timesheets. The following pages should show the exact same banner as here.
smil:*
attributes
smil-*
attributes
data-*
attributes
data-*
attributes have to
be lowercase.
Timesheets are another way to use SMIL Timing in an HTML document. It’s comparable to CSS: you can use inline styles in your document or you can describe most of the presentation with internal or external stylesheets.
As for CSS stylesheets, using SMIL Timesheets instead of inline SMIL Timing allows to factorize some markup and reuse the same timesheet in several web pages. For instance, the External Timesheets page shows how to get a single timesheet that would work for any number of images in the banner.
In these pages, the markup is described with smil:
prefixes
because we think it makes more sense that way; but under the hood we’re
using data-*
attributes instead, in order to be compatible
with IE<9 and to pass the W3C validator.