Fatal's Journal

Build dynamic Web presentations without Flash

, , , , , , , ,

Just a week ago Chris Mills said that he is "planning a series of articles to show that you can really do all Flash type stuff using open standards". He also asked thoughts on what to cover. And in a couple days I stumble upon Flash photo portfolio presentation in New Yorker magazine and decided to convert it to standards. It looked pretty doable with CSS and JavaScript to me, so I decided to go with CSS-only, because I'm interesting in trying out some upcoming CSS3 goodies.

If you don't want to go into implementation details, here is a demo (alternative link). Sorry for stupid My Opera nag screen, no harm will be provided to you or your computer. Also you will need Google Chrome 4 or Safari 4 or Firefox 4 or Opera with Presto 2.3+ engine.

So, I started with examining the Flash presentation sample. Thankfully it appears that creators separated data (XML and pictures) from presentation (Flash), so anyone can pretty easily create their own implementation.

To locally saved XML I applied small XSL, that generated HTML markup for presentation, and that was pretty straightforward.

Here is most interesting part of HTML structure:
<div id="name">
  <div id="country">
    <div id="age">
      <div id="gender">
        <div id="tenure">
          <p id="menu">Order by:
            <a href="#name" id="menu-name">Name</a>
            <a href="#country" id="menu-country">Country</a>
            <a href="#age" id="menu-age">Age</a>
            <a href="#gender" id="menu-gender">Gender</a>
            <a href="#tenure" id="menu-tenure">Tenure</a>
          </p>
          <ul> 
            <li>...</li>
            <li>...</li>
            ...
          </ul>
        </div>
      </div>
    </div>
  </div>
</div>

Now it was CSS turn. In two words: using :target pseudo-class I was able to switch sorting of photos, using CSS3 transitions I was able to show "visual sorting" and smooth fade-in-out effects. To show big pictures I decided to use :active pseudo-class (user needs to hold mouse button on a thumbnail). From CSS3 I also used RGBA and box-shadow.

Here is an example of current CSS nightmare that we need to write in order to get all current and future browsers on board:
-webkit-transition-property: opacity;
-webkit-transition-duration: .6s;
-webkit-transition-delay: .6s;
-moz-transition-property: opacity;
-moz-transition-duration: .6s;
-moz-transition-delay: .6s;
-o-transition-property: opacity;
-o-transition-duration: .6s;
-o-transition-delay: .6s;
transition-property: opacity;
transition-duration: .6s;
transition-delay: .6s;

Once CSS3 transitions module will become a recommendation, we will need to add properties without vendor prefixes.

That is pretty much it. This CSS-only demo doesn't cover all functionality of original presentation, but sure that is 100% doable if we add some JavaScript and any technology to play audio files.

I tested this demo in Google Chrome 4, Apple Safari 4, and Mozilla Firefox 3.7 builds. Firefox seems has some glitches with CSS transitions, but it is useful even in this state. I added -o- prefixes, so someone can test this on Opera Mobile 10 (Presto 2.3) or next Opera for desktop (Presto 2.4).

Any comments, suggestions and corrections are welcome.

Opera wish-list guide: restore detach of tabsOpera Mobile 14 beta testing

Comments

Nikita VasilyevELV1S Tuesday, December 8, 2009 10:14:32 PM

Sorting is awesome!

ouzowtfouzoWTF Tuesday, December 8, 2009 10:17:01 PM

very very nice! love

Martin RauscherHades32 Tuesday, December 8, 2009 11:36:57 PM

WOW! That's the most impressing CSS-only thing I've ever seen! Great!

But chrome doesn't seem to keep :focus after I release the mouse button...

FataL Wednesday, December 9, 2009 12:00:21 AM

But chrome doesn't seem to keep :focus after I release the mouse button...

I used :active pseudo-class, not :focus.
So it is meant to behave like this.

MyOpera team, please fix this!fearphage Wednesday, December 9, 2009 10:52:49 AM

Originally posted by FataL:

Sorry for stupid My Opera nag screen, no harm will be provided to you or your computer

I'd say give up on myopera as file hosting. I did. The upload interface sucks and the nag screen is a pain. I use dropbox now which is not meant for that but it has a public folder to let you share what you want and since it's disk-based, you just copy files into a folder and you're done... and they are versioned. It also has a web interface so you can access your files from anywhere and it syncs the files to all of your computers/phones with the dropbox client installed.</endorsement>

The demo link is down/404'd or something's wrong.

Charles SchlossChas4 Wednesday, December 16, 2009 2:15:45 AM

One other plus of using open standards over flash is the cpu usage on the end users machine is a lot less than flash

MyOpera team, please fix this!fearphage Wednesday, December 16, 2009 5:57:24 PM

I have a suggestion for the demo. CSS sprites! 1 large image instead of n.

FataL Wednesday, December 16, 2009 6:09:01 PM

Originally posted by fearphage:

I have a suggestion for the demo. CSS sprites! 1 large image instead of n.

CSS sprites means I need to use background images. But then I can't scale up thumbnails. smile

Anodynetherealanodyne Saturday, April 10, 2010 7:34:40 AM

Absolutely fantastic, great job,
thanks for sharing it.

Peace wishes,
Anodyne

Андрей Охотниковdarvolok Monday, January 23, 2012 9:49:47 AM

I have a suggestion for the demo. CSS sprites!

Андрей Охотниковdarvolok Monday, January 23, 2012 9:49:47 AM

I have a suggestion for the demo. CSS sprites!

Write a comment

New comments have been disabled for this post.

June 2013
M T W T F S S
May 2013July 2013
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30