Created
January 13, 2010 11:32
-
-
Save benfoxall/276124 to your computer and use it in GitHub Desktop.
minimal image enlarge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// intercept rel=image clicks and make images fade in over the top | |
$$('a[rel=image]').each(function(link){ | |
link.observe('click',function(e){ | |
Event.stop(e); | |
i = new Element('img'); | |
i.observe('load',function(){ | |
$('image_mask').appear() | |
}) | |
// do this afterwards for IE | |
i.writeAttribute('src',$(this).readAttribute('href')); | |
$('image_mask').update(i); | |
}.bindAsEventListener(link)) | |
}) | |
//hide the image when the page is clicked | |
$('image_mask').observe('click',function(){ | |
$('image_mask').fade({afterFinish:function(){ | |
//once hidden, remove it | |
$('image_mask').update(''); | |
}}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="image_mask" style="display:none"></div> | |
<a href="the-image.jpg" rel="image"><img src="the-thumbnail.jpg" /></a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#image_mask { | |
text-align:center; | |
background-color:#fff; | |
width:100%; | |
height:100%; | |
position:absolute; | |
} | |
#image_mask img{ | |
margin:auto; | |
padding: 40px 0 40px 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment