The Polaroid Photo Viewer-Non-Full Screen

11 January 2010 Monday

This application was viewed 1348 times




The Polaroid Photo Viewer - Non-Full Screen

Pretty fast after I placed the Polaroid Photo Viewer with CSS3 and jQuery example online, I received loads of e-mails and comments requesting another feature. The original example was only full-screen, but people wanted it to "stick" to a box (Placing it inside a <div>).

Try dragging the polaroids around in the demo. You´ll be able to do so, but the surrounding division seems to prevent the user from actually dragging it outside it´s container.

Just like with the original example, this example only works on modern browsers supporting CSS3 (Safari, Chrome and Firefox 3.5). This probably would work with Opera too, but I haven´t tested it.

Now to show you which small changes are made to the original script to make this one work.

View the DEMO

First things first

Since we´re not making the script full-screen anymore, we might want to trim down everything. This simply means:

  • Resizing all images (Polaroid background and foreground)
  • Trimming down the font-size in CSS
  • Changing some other static (yeah - it´s a bad thing) values in the CSS

This will leave us with a simple, "minified-version" of the original script (just small polaroids). Now that´s something we can work with.

HTML

So, let´s do the most basic (but important!) step in the HTML. This is what we had at first.

 
<div class="polaroid">
  <img src="images/01_colosseum.png" alt="Colloseum" />
  <p>Coloseum in Rome</p>
</div>
<div class="polaroid">
  <img src="images/02_vatican.png" alt="Vatican" />
  <p>Vatican</p>
</div>
<!-- More images here -->

Since we´ll need it to be locked to a surrounding container, this is the most obvious step to make:

 
<div id="polaroidcontainer">
  <div class="polaroid">
    <img src="images/01_colosseum.png" alt="Colloseum" />
    <p>Coloseum in Rome</p>
  </div>
  <div class="polaroid">
    <img src="images/02_vatican.png" alt="Vatican" />
    <p>Vatican</p>
  </div>
  <!-- More images here -->
</div>

And that´s what we´re going to work with (On the demo page, I added some extra information but that´s not necessary)!

jQuery

Apart from the changes made in the first step (trimming everything down), we don´t need to change the CSS; only jQuery. The following change is the most important one.

This was the original code:

 
// Make the polaroid draggable & display a shadow when dragging
$(".polaroid").draggable({
  cursor: ´crosshair´,
  // More draggable stuff here
});

Now the following is added, which is vital to make the script work:

 
// Make the polaroid draggable & display a shadow when dragging
$(".polaroid").draggable({
  containment: ´parent´,
  cursor: ´crosshair´,
  // More draggable stuff here
});

Tags: polaroid, jquery, gallery,


The Polaroid Photo Viewer-Non-Full ScreenBookmark and Share

You write your thoughts

Please login to post comments here from the right corner.

your add
icon free icon icon set vector icon free catalog catalog template jquery news ticker widget tools tutorial php slider video youtube effects menu thumbnail forms facebook zoom image combo multiselect modal polaroid gallery expand code feedback contact navigation slider tagcloud Skateboard psd templates files badges subscribe panel login temlate file free office holland free template tabs prototype css scriptaculous opacity moo autocomplete wordpress themes design theme button images photoshop fonts font nav pdf logo style high javascript pretty photo jqery lightbox Themes Blog popular blog desing joomla xhtml brushes hair footer admin mootols slide show blackbox new download class first plugin upload browse Page effect modalbox web application urlitooltips sliding boxes captions flatchat chat ajax messaging browser hoverlightbox CSS Dev General Javascript PHP SQL search avatar vector Drupal Joomla Oscommerce javaScript phototype manager ajaxplorer flash xml rotator bookmarking pageflip slideshow poll text component script mediaplayer imagegallery pictograms car poster player mp3 radio onlineradio navigations drop-down collection brush tree textures paper pop-up bumpbox web2.0 iphone film frame twitter page fan mail delete dynamic calender form handbook city social paint timeline clock connect bar sharing accordion quotes ticker photo-effects background 3D media player graphic rss leaf green glossy bubble icon comic clean cool web 2.0 png actionscript ietter rotating Menu animated textured site masking pasword app layer sponge bob popup bubble tooltips horizontal prototip tooltip pack charachters comics blog action icon.psd flavour navi tango gradients istanbul mixed css3 sleek animations program html5 website Layer styles ultimate candy Media icons dropdown snow icon innerfade hover sub tag