You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

The Apple effect for overlay


Overlay demo 2 / 8 : The Apple effect for overlay

Here you can see an Apple effect in action:

Berlin Gustavohouse

The Gustavo House in Storkower Strasse. It was built in 1978 and reconstructed in 1998 by the Spanish artist Gustavo.

Berlin Alexanderplatz Station

Berlin Alexanderplatz is a railway station in the Berlin city centre and is one of the city's most important interchange points for local public transport.

Apple effect performs overlaying in a visually appealing manner by growing a background image from 0 to the desired size. This differs from "regular" overlaying solutions that do overlaying with static DIVs. The downside is that you are tied to the dimensions of the image. You can change the width but the height scales accordingly so that the aspect ratio remains constant.

HTML setup

The HTML setup is identical to the minimal setup for overlay. There are trigger elements and their corresponding overlay elements.

<!-- trigger elements -->
<img src="photos/gustavohouse.jpg" rel="#photo1"/>
<img src="photos/alexanderplatz-station.jpg" rel="#photo2"/>

<!-- overlay for the first trigger. id matches the rel- attribute -->
<div class="overlay black" id="photo1">
	<img src="photos/gustavohouse-medium.jpg" />

	<div class="details">
		<h2>Berlin Gustavohouse</h2>

		<p>
			The Gustavo House in Storkower Strasse. It was built in 1978 and reconstructed in
			1998 by the Spanish artist Gustavo.
		</p>
	</div>
</div>

<!-- overlay for the second trigger -->
<div class="overlay" id="photo2">
	...
</div>

CSS coding

Some important things about the CSS coding of this effect:

We are using the overlay-apple.css stylesheet which looks like this:

/* the overlayed element */
.apple_overlay {
	
	/* initially overlay is hidden */
	display:none;
	
	/* growing background image */
	background-image:url(../img/overlay/white.png);
	
	/* 
		width after the growing animation finishes
		height is automatically calculated
	*/
	width:640px;		
	
	/* some padding to layout nested elements nicely  */
	padding:35px;

	/* a little styling */	
	font-size:11px;
}

/* default close button positioned on upper right corner */
.apple_overlay .close {
	background-image:url(../img/overlay/close.png);
	position:absolute; right:5px; top:5px;
	cursor:pointer;
	height:35px;
	width:35px;
}

You can use any browser-renderable background image with overlay. However, using PNG images allows you to have neat drop shadows in your overlays, since PNG supports alpha transparency, while GIF and JPG images do not. You can use the same background image at different sizes without experiencing significant quality degradation.

IE6 issues

IE6 does not support alpha-transparency for the overlays so we have used a different background for that browser:

<!--[if lt IE 7]>
	<style> 
	div.apple_overlay {
		background-image:url(http://static.flowplayer.org/tools/img/overlay/overlay_IE6.gif);
		color:#fff;
	}
	
	/* default close button positioned on upper right corner */
	div.apple_overlay div.close {
		background-image:url(http://static.flowplayer.org/tools/img/overlay/overlay_close_IE6.gif);
	
	}	
	</style>
	<![endif]-->

Black "skin"

You can easily change the look of the overlay simply by changing the background image. In our example above we used black and white backgrounds. For the black overlay we have the class name "black" and its configuration is here:

/* black version of the overlay. simply uses a different background image */
	div.apple_overlay.black {
		background-image:url(http://static.flowplayer.org/tools/img/overlay/transparent.png);		
		color:#fff;
	}

JavaScript coding

Here is the overlay configuration. We specify our "apple" effect with the effect configuration variable.

$(function() {
	$("#apple img[rel]").overlay({effect: 'apple'});
});

Note: this effect is not included in the standard jQuery Tools distribution. You must download a custom combination that includes this effect.

Show this demo as a standalone page.

Photo credits »