Page Peel Effect Using MooTools

Written by David Walsh on Tuesday, September 8, 2009


Peel Effect

Soh Tanaka release a great script back in May titled Simple Page Peel Effect with jQuery & CSS. The idea is that you place a “peel” image on the upper-right side of an element which, when hovered, “peels” open and peels close. I thought this was a quality, flexible idea so I’ve ported the jQuery code to MooTools.

The XHTML

<div id="page-flip">
	<a href="http://feeds.feedburner.com/BluDice"><img src="page_flip.png" alt="Subscribe!" id="page-flip-image" /></a>
	<div id="page-flip-message"></div>
</div>

A wrapper DIV containing an image and a “message” DIV.

The CSS

#page-flip { position:relative; right:0; top:0; float:right;  }
#page-flip-image { width:50px; height:52px; z-index:99; position:absolute; right:0; top:0; -ms-interpolation-mode:bicubic; }
#page-flip-message { width:50px; height:50px; overflow:hidden; position:absolute; right:0; top:0; background:url(subscribe.png) no-repeat right top; }

These initial CSS is important as we’ll be modifying this initial CSS with MooTools.

The MooTools Javascript

(function($,$$) { window.addEvent('domready',function() {
	
	var flip = $('page-flip');
	var flipImage = $('page-flip-image');
	var flipMessage = $('page-flip-message');
	
	flip.addEvents({
		mouseenter:function() {
			$$(flipImage,flipMessage).set('morph',{ duration: 500 }).morph({
				width: 307,
				height: 319
			});
		},
		mouseleave:function() {
			flipImage.set('morph',{ duration: 220 }).morph({
				width: 50,
				height: 52
			});
			flipMessage.set('morph',{ duration:200 }).morph({
				width: 50,
				height:50
			});
		}	
	});
}); })(document.id,$$);

The peel effect is triggered by mouseenter and mouseleave events on the outter DIV element. You’d think there was more to it but the effect is driven simply by width and height animations.

What do you think about this effect? Would you use it? Too “flashy?” Share!


Follow via RSS Epic Discussion

Commenter Avatar September 08 / #
Marcel says:

That looks really static. I would prefer a “realistic” solution.

Commenter Avatar September 08 / #
Ahmad Azimi says:

Hi,

I have a question:
Why are you using document.id instead of $? Is there any performance improvement?

Commenter Avatar September 08 / #
Adriaan says:

Interesting, I’ve never heard of “-ms-interpolation-mode” before…seems handy though…

Commenter Avatar September 08 / #
Darkimmortal says:

-ms-interpolation-mode:bicubic;

Cool, that should come in handy :>

Commenter Avatar September 08 / #

-ms-interpolation-mode:bicubic;

It makes images look nicer that have been resized, but don’t apply it to all (or even more than a couple) img tags. There’s a reason it’s not on by default: it’s significantly slower to render.

Commenter Avatar September 09 / #

@Ahmad Azimi

MooTools 1.2.3 DOM stuff doesn’t depend on the presence of $ anymore. The method that used to be $ is now called document.id (short for identify). The method $ is still assigned when not already present in the page, and aliased to document.id.

Blog entry (MooTools.com)

Commenter Avatar September 10 / #

I’m not sure if I’d ever use that effect but it’s pretty cool. Nice to see how easy it is to do with MooTools.

Commenter Avatar September 16 / #
Michael says:

I have searched for such a script long time, now i have a solution how to go. Thank you. I love your blog and your scripts.

Commenter Avatar September 18 / #
Try2Love says:

Thanx Dude………… This is superb idea to utilize……….

Commenter Avatar November 22 / #
Alexander says:

Thanks for this, you rock!

Commenter Avatar December 03 / #

Hi!,

Thanks for this but as I have several code with 1.11 I need this code to work on 1.11.

I know that the mouseenter & mouseleave was developed for 1.2 so, is there a way to change this into 1.11?

I’m really newbiw with javascript so, I hope you can help me.

Greetings

Commenter Avatar January 29 / #
The-F says:

Yes, could you please port this in Mootools 1.1 too?

Be Heard!

I want to hear what you have to say! Share your comments and questions below.

Name*:
Email*:
Website:  


© David Walsh 2007-2010. Contact David Walsh. Powered by the remarkable MooTools javascript framework.