Reflection.js 1.6

July 14th, 2006

Reflection.js is a cross platform script which allows you to add reflections to images on your web pages.

Reflection.js

It works in all the major browsers - Internet Explorer 5.5+, Mozilla Firefox 1.5+, Opera 9+ and Safari. On older browsers, it’ll degrade and your visitors won’t notice a thing. Best of all, it’s under 5KB.

What’s New?

Just a small bug fix update to Reflection.js fixing two bugs:

  • Don’t create a <div> in browsers not supporting canvas but supporting JS
  • Fix gap between image and reflection in XHTML Strict

Demo

See a demo of reflection.js 1.6 in action.

The reflection.js download includes some more examples of how reflection.js can be used including varying the height, opacity and responding to user actions.

Thank you!

I should once again say thanks to all the people who’ve used the script, left their feedback and helped iron out any issues. If you’ve used the script on one of your sites or galleries, please leave a comment! It’s great seeing how people put this script to use. 

  1. Reflection.js 1.7
  2. Reflection.js 1.9
  3. Reflection.js 1.8
  4. Reflection.js 2.0
  5. Reflection.js version 1.5

151 Responses to “Reflection.js 1.6”

  1. Khloon 14 Jul 2006 at 5:44 pm

    If you’ve got any questions on how to use Reflection.js or problems, it’s worth taking a look around the comments for version 1.5 too. The usage of the two versions are the same.

  2. Giggseyon 17 Jul 2006 at 3:19 pm

    Not sure, but this is weird.

     Did the refloectomatic for http://www.appliedwebhost.com/temp.gif and the image doesn’t appear right in the reflection.

     

    Free Image Hosting at <a href=http://www.ImageShack.us” />

  3. Khloon 17 Jul 2006 at 4:46 pm

    That’s kinda strange. There is a known issue with Firefox and GIF transparencies so this may be to do with it.

  4. Paul Westbrookon 18 Jul 2006 at 8:49 am

    I created a plugin wrapper for LifeType to allow users of LifeType to use Reflection.js.

    Reflection.js was very easy to integrate.  

     

    Thank you,

    Paul 

  5. Jonon 29 Jul 2006 at 2:01 pm

    Hi Khlo!

    I have applied the Reflections 1.6 and my Lightbox mod and for some strange reason it isn’t working in IE. Firefox is fine. I did notice however it doesn’t seem to matter what version of Reflections it is. I have pin pointed it down to the Lightbox.js. It seems to be doubling the size of the background needed. Any help would be greatly appreciated. Here’s the link http://www.comfypad.com/test.php

    Thanks

     

    Jon 

  6. Jonon 29 Jul 2006 at 2:11 pm

    Scrap that last comment!

    It is the reflections file, 1.5 is fine 1.6 seems to double the size of the image in the lightbox.

    Just thought I should let you know

  7. Planneron 06 Aug 2006 at 4:18 pm

    Absolutly fabulous. I just installed rmagick and graphicsmagick to make reflective images for my site and then I stumbled on this. Great job! will test  it out in a day or two. The sample reflections looks far better than once I’ve seen.

    Kudos! 

  8. Andrea Giammarchion 07 Aug 2006 at 11:48 am

    less than 5 Kb ?

    why shouldn’t be less than 4 Kb

     

    // getElementsByClassName with JSL [http://www.devpro.it/JSL/]document.getElementsByClassName = function(className) {	var 	result = [], re = new RegExp("\\b".concat(className, "\\b"));	for(var i = 0, list = document.getElementsByTagName("*") || document.all, j = list.length; i < j; i++)		result.push(list[i]);	return result.filter(function(){return re.test(arguments[0].className)});};
    
    var Reflection = {	defaultHeight : 0.5,	defaultOpacity: 0.5,	add:	function(image, options) {		var	reflectionHeight = 0,			div = document.createElement("div"),			reflection = {}, context = {}, gradient, doptions = {"height":this.defaultHeight, "opacity":this.defaultOpacity};		this.remove(image);		if(options) {			if(!options.height)				options.height = doptions.height;			if(!options.opacity)				options.opacity = doptions.opacity;		}		else			options = doptions;		reflectionHeight = Math.floor(image.height * options.height);		div.className = image.className.replace(/\breflect\b/, "");		image.className = "reflected";		div.style.cssText = image.style.cssText;		image.style.cssText = "vertical-align: bottom";		if(document.all && !window.opera) {			reflection = document.createElement("img");			reflection.src = image.src;			reflection.style.width = image.width + "px";			reflection.style.marginBottom = "-".concat(image.height - reflectionHeight, "px");			reflection.style.filter = "flipv progid:DXImageTransform.Microsoft.Alpha(opacity=".concat(options.opacity*100, ",style=1,finishOpacity=0,startx=0,starty=0,finishx=0,finishy=", options.height*100, ")");		}		else {			reflection = document.createElement("canvas");			reflection.style.height = reflectionHeight + "px";			reflection.style.width = image.width + "px";			reflection.height = reflectionHeight;			reflection.width = image.width;			context = reflection.getContext("2d");			context.save();			context.translate(0,image.height-1);			context.scale(1,-1);			context.drawImage(image, 0, 0, image.width, image.height);			context.restore();			context.globalCompositeOperation = "destination-out";			gradient = context.createLinearGradient(0, 0, 0, reflectionHeight);			gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");			gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options.opacity)+")");			context.fillStyle = gradient;			if (navigator.appVersion.indexOf("WebKit") !== -1)				context.fill();			else				context.fillRect(0, 0, image.width, reflectionHeight*2);		};		div.style.width = image.width + "px";		div.style.height = Math.floor(image.height*(1+options.height)) + "px";		image.parentNode.replaceChild(div, image);		div.appendChild(image);		div.appendChild(reflection);	},	remove:	function(image) {		if (image.className == "reflected") {			image.className = image.parentNode.className;			image.parentNode.parentNode.replaceChild(image, image.parentNode);		}	}};
    
    function addReflections() {	for(var i = 0, rimages = document.getElementsByClassName("reflect"); i < rimages.length; i++) {		var rheight = null, ropacity = null, classes = rimages[i].className.split(' ');		for (var j = 0; j < classes.length; j++) {			if (classes[j].indexOf("rheight") == 0)				rheight = classes[j].substring(7)/100;			else if (classes[j].indexOf("ropacity") == 0)				ropacity = classes[j].substring(8)/100;		};		Reflection.add(rimages[i], { height: rheight, opacity : ropacity});	}
    
    };
    
    var previousOnload = window.onload;window.onload = function () { if(previousOnload) previousOnload(); addReflections(); } 
  9. Patrick Thomassenon 07 Aug 2006 at 9:20 pm

    Too bad that you can’t put a link in the image you’re reflecting.

     

  10. Martin Dunkelon 11 Aug 2006 at 1:43 pm

    I’ve tested your great JS in a lot of browsers and only in IE it is not possible to set an anchor and link the image with reflection Will it be possible in next version? Thanks for your great job!

  11. Simoneon 16 Aug 2006 at 10:04 pm

    Hello, I’ve been trying to find out a way to send you some feedback but it looks like there’s no contact form in your portal. BTW, I wanted to let you know that I’ve created an extender control for the Atlas Control Toolkit by Microsoft with your reflection script. You can find my blog post about it here.

  12. Davidon 17 Aug 2006 at 5:19 am

    Here’s a quick and dirty work-around the the IE link issue. Add this at line 78 in the script:

    if (p.parentNode.href) {
    p.style.cssText = ‘cursor: pointer;’;
    p.onclick = function () { window.location = p.parentNode.parentNode.href; };
    }

  13. Ramon Finckenon 18 Aug 2006 at 7:28 pm

    Comment on:

    http://cow.neondragon.net/stuff/reflection/

     

    1) phpBB Reflection - phpBB Modification has an error: check the double class="

    2) Full integration into phpbb: http://phpbbinstallers.com/board/viewtopic.php?p=1910#1910&nbsp;

  14. Benon 20 Aug 2006 at 12:02 pm

    if you’re using prototype.js with this you’d better take out the

    getElementsByClassName function in reflection.js because it will break any code you have that relies on prototype’s implementation (which lets you to filter by parent container as well as document). Spent hours trying to figure out why my getElementsByClassName were suddenly returning ALL elements in my document.

  15. Khloon 28 Aug 2006 at 2:17 pm

    Thanks for the comments and thoughts; Ramon - I’ll add the link to the phpBB modification to the reflection.js page.

  16. Tanhnhion 31 Aug 2006 at 11:45 am

    Great job,

    Images embedded in tag is not correctly reflected under firefox, it’s because firefox automatically add borders to images embedded in . So additional css retouch should be considered if you want to integrate the effect.

    A margin of about 2-3px between the original image and the canvas would be better, it helps people recognize the original image! What do you think?? I’ve succesfully integrated reflection.js into my site http://shawking.free.fr

  17. Tanhnhion 31 Aug 2006 at 11:47 am

    I’d like to say images embedded in tag A

  18. Bijuon 02 Sep 2006 at 7:57 pm

    See bug#351113 at

    https://bugzilla.mozilla.org/show_bug.cgi?id=351113

     

  19. Slvenon 13 Sep 2006 at 6:20 pm

    Great job, and i’d like to know if i’m a blogger beta user can i use Reflection.js? Thanks.

  20. Haackedon 14 Sep 2006 at 11:08 pm

    Very cool!  I tested this out and I get a weird gap in Firefox.

    http://haacked.com/archive/2006/09/14/Yay_More_Gratuitous_Special_Effects_For_My_Blog__Reflections.aspx&nbsp;

  21. Haackedon 14 Sep 2006 at 11:08 pm

    I forgot to mention, it seems to work fine in IE 6

  22. Stefanon 16 Sep 2006 at 6:05 pm

    I’ve got a problem with images which are also a link to a webpage. In Firefox, it works perfect, buf if you want to click on a image with reflection and when it’s also a link, it appears that it doesn’t load.

  23. Stefanon 16 Sep 2006 at 6:21 pm

    I’ve got a simple - but not better - solution. Use the onclick action :)

    <img src="test.jpg" class="reflect rheight32" onclick="window.location=’index.php’" style="cursor:pointer;" />

     Than it will work as a link again. But I hope you can fix the problem without this Onclick action ;)

  24. Gian Luca Pontion 18 Sep 2006 at 10:26 am

    I think it is great! very cool!
    I had only a little problem with images inside a DIV with text-align: center;
    If i apply reflection to these, images will align to the left side of the div.
    any suggestion?

  25. Douglason 24 Sep 2006 at 12:41 am

    Documentation says have to have reflection.js and prototype.js

    Downloaded 1.6 zip file does not contain prototype.js

    Where is it?

  26. Khloon 24 Sep 2006 at 11:37 am

    Whoops; Reflection.js 1.6 doesn’t require Prototype.js anymore. This must be a documentation mistake.

  27. Chrison 24 Sep 2006 at 1:42 pm

    Hi, Great Stuff.

     One problem I am having,

    If I have an onLoad event on the page the reflection does not appear.

     This is driving me nuts - any suggestions VERY gratefully recieved

  28. Khloon 24 Sep 2006 at 2:40 pm

    Hi,

    I believe the onload="" attribute on the body element is deprecated. Instead of assigning it there, you could use a <script> block in the head portion of your page and use window.onload = onloadFunc;.

    Alternatively, you could try including the reflection.js script after the <body onload> tag; I’m not 100% sure if this works.

    Reflection.js will play nicely with any existing onload events - usually it’s another script overwriting Reflection’s onload event which causes the problem. 

  29. Chrison 24 Sep 2006 at 6:59 pm

    Hi Khol,

     Thanks a lot for this -

     I have changed the onload to window.onload and then included reflection.js AFTER the window.onload call and everything is now working great.

     

    Thakns again

  30. Marcus Crafteron 25 Sep 2006 at 10:13 am

    Hi There,

    Hope all is going well.

    Thanks for your work on the reflection.js library, top stuff!

    I’ve integrated it into Typo, the Rails based weblog engine for others to take advantage of as well:

    http://crafterm.net/blog/articles/2006/09/25/reflective-images-in-typo-using-plugins

    Cheers,

    Marcus

  31. Khloon 25 Sep 2006 at 3:19 pm

    Thanks for the info; I’ve added it to the implementations page.

  32. Batsion 30 Sep 2006 at 11:33 pm

    Hi great script - working in Firefox and IE. I want to add a 1px gap between the image and reflection. I have done this is Firefox - I changed this line:

                        context.drawImage(image, 0, 0, reflectionWidth, image.height);

    to

                        context.drawImage(image, 0, -1, reflectionWidth, image.height); 

     

    But IE doesn’t seem to respond. Firefox is perfect. Any ideas on what to change to get the 1px gap in IE.

     

  33. Khloon 01 Oct 2006 at 11:35 am

    Hi,

    This is because this is the codepath for non-IE browsers. For IE, you’ll have to modify the bit of code around:

    				reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')';

    Which is found above. 

     

  34. Geoffreyon 02 Oct 2006 at 1:33 am

    Hello and thank you so much for this great script.

    I’m running an internet station and i’m using your script along with the cover cd picture of the song on air. It was just working fine ’till i switch the display of the cd cover picture in AJAX in order to avoid our listeners to reload the page to check the song on air. Since, it’s just not working as i’m using the div display system:

    <div id=’tablePrices’ align="left"></div>
    <div id=’divTrade’ align="left"></div>
    <div id=’showLoading’ align="left"></div>

    Have you got any suggestion? I’m about to become crazy right now. If you want to check the website dev., just ask, i’ll drop you the url.

    Regards,
    Geoffrey.

  35. Khloon 02 Oct 2006 at 9:07 am

    Hi there,

    You’ll have to call Reflection.add() on the image which is reflected to update the reflection. See the documentation for parameters on how to use this but Reflection.add(document.getElementById(’coverid’)) should work. 

  36. Geoffreyon 02 Oct 2006 at 1:34 pm

    Hello,

    Thank you very much for the quick answer. I’ll be honest with you, i actually don’t have the skill required to get exactly what you’ve just ask me to do. About this snippets of code, should i put it directly into the div id? img src? The ‘coverid’ should match the id of the div where my img src is?

    Enlighten me please… Merci beaucoup pour ta patience.
    Geoffrey.

    You can take a look of the problem here: http://www.hitmusicstation.net/__v3/ Look at the upper left.

  37. Khloon 02 Oct 2006 at 4:02 pm

    Hi,

    Nice site Basically straight after the AJAX code where you change the src value of the img tag, you add the following line:

    Reflection.add(document.getElementById("albumcover"));

    Change albumcover to the id of the image tag

    I can’t see exactly where in your example the album cover is or the code you are using to change the url to the album cover but if you paste the relevant code I’ll see if I can look into it further. 

  38. Geoffreyon 02 Oct 2006 at 8:25 pm

    Hello,

    thank you very much for the great comment… it’s costing us a lot of work… but we are hoping to do something really great. Here is the code for the display of the picture into the Ajax function printPrices() :

                                           $req_last_titre = mysql_query("SELECT artiste, titre, date FROM hms_music WHERE artiste != ‘HMS’ AND artiste != ” ORDER BY date DESC LIMIT 1");
                                            while($res_last_titre = mysql_fetch_array($req_last_titre)) {
                                                echo ”;
                                                       
                                                        $chemin_pochette = ‘../image/pochettes/’.str_replace("`","’",$res_last_titre['artiste']).’ - ‘.str_replace("`","’",$res_last_titre['titre']).’.jpg’;
                                                        if (file_exists($chemin_pochette)) {
                                                            $text = ‘<a href="/titre_’.urlencode($res_last_titre['artiste']).’_’.urlencode($res_last_titre['titre']).’.html" onmouseover="return overlib(\”.$res_last_titre['titre'].’\', CAPTION, \”.$res_last_titre['artiste'].’\');" onmouseout="return nd();"><img src="’.$chemin_pochette.’" width="158" height="100" border="0" class="reflect rheight15 ropacity45"></a>’;
                                                        }
                                                        else {
                                                            $text = "<a href=\"/titre_".urlencode($res_last_titre['artiste'])."_".urlencode($res_last_titre['titre']).".html\" onmouseover=\"return overlib(’".$res_last_titre['titre']."’, CAPTION, ‘".$res_last_titre['artiste']."’);\" onmouseout=\"return nd();\"><img src=\"/image/pochettes/pochette.jpg\" width=\"158\" height=\"100\" border=\"0\" class=\"reflect rheight15 ropacity45\" ></a>";
                                                        }
                                                        echo ”;
                                                   
                                            }

    The result is displayed into these three lines:

    <div id=’tablePrices’ align="left" style="text-align:center; background-image:url(’images/fondonair.jpg’);"></div>
    <div id=’divTrade’ align="left"></div>
    <div id=’showLoading’ align="left"></div>

    I really hope that you could help us… as i still don’t get it… *sic*

    Regards,
    Geoffrey.

  39. Khloon 02 Oct 2006 at 8:52 pm

    Hi,

    Are you using Javascript to do a XmlHttpRequest call and setting the innerHTML based on the response of the request?  

  40. Geoffreyon 02 Oct 2006 at 9:10 pm

    Yes, exactly.

    I’m using the AJAX Agent framework available here: http://www.hemmady.com/ajaxagent and here is the script function:

    <script>
      function call_trade(str) {
        agent.call(”,’trade’,'callback_trade’,str);
      }

      function callback_trade(str) {
        document.getElementById(’divTrade’).innerHTML = str;
      }

      function call_printPrices() {
         call_setLoading();
        agent.call(”,’printPrices’,'callback_printPrices’);
      
        setTimeout(’call_printPrices()’,5000);
      }

      function callback_printPrices(str) {
         call_unsetLoading();
        document.getElementById(’tablePrices’).innerHTML = str;
      }
     
      function call_setLoading() {
        callback_printLoading(”);
      }
      function call_unsetLoading() {
        callback_printLoading(’ ‘);
      }
      function callback_printLoading(str) {
        document.getElementById(’showLoading’).innerHTML = str;
      }
      function init()  {
         call_printPrices();
      }

    </script>

    Geoffrey.

  41. Khloon 02 Oct 2006 at 10:33 pm

    Hi,

    Try adding an id="" attribute to the image tag and then add the Reflection.add() code from above after the innerHTML bit. 

  42. Geoffreyon 02 Oct 2006 at 11:46 pm

    Hello,

    I just did what you’ve asked. It is working actually with this code:

      function callback_printPrices(str) {
         call_unsetLoading();
        document.getElementById(’tablePrices’).innerHTML = str;
        Reflection.add(document.getElementById("pochette"));
      }

    We are not so far from the answer to be honest. Still one problem, it seems that the parameters rheight15 ropacity45 aren’t taken in count as you can see on the page. Any suggestion here? I feel very sorry to bother you with this to be honest, but my skill with javascript is really near from the absolute zero.

    Regards,
    Geoffrey.

  43. Khloon 03 Oct 2006 at 9:35 am

    Hi there,

    To set the height & opacity using the Reflection.add() function we need to add a few options. The following should do the job:

         Reflection.add(document.getElementById("pochette"), { height: 0.15, opacity: 0.45});

    Hope this helps! 

  44. Geoffreyon 03 Oct 2006 at 11:50 am

    Hello,

    it’s just working perfectly now! Thank yo much! I hope that will help others…

    Merci mon ami.
    Geoffrey,
    FRANCE.

  45. Christophe Beylson 05 Oct 2006 at 2:25 am

    I made an optimized version of your great script.
    I just want to inform you that you can replace:

    if (navigator.appVersion.indexOf("WebKit") !== -1)	context.fill();else	context.fillRect(0, 0, image.width, reflectionHeight*2);

    with

    context.rect(0, 0, image.width, reflectionHeight);context.fill();

    This way you don’t need browser-specific code for the canvas.
    Also I don’t know why you used reflectionHeight*2 … You don’t need to multiply the height.

    Christophe Beyls, Brussels, Belgium

    PS: This WYSIWYG comment editor sucks!

  46. Anthony Nguyenon 05 Oct 2006 at 10:17 pm

    I posted this in the 1.5 comments area. Hope you don’t mind a double post:

    Sorry if this has already been answered! Those are a lot of comments to read through! I’m not sure if I’m doing something wrong or if the script intentionally does it, but I can’t link the images. Please let me know! Thanks! BTW, awesome!!! Saves me loads of time since I don’t have to go through GIMP or PhotoShop.

  47. Anthony Nguyenon 11 Oct 2006 at 5:55 am

    Hey! I actually found out that Firefox and Opera link the images fine. IE6, however, seems to not like linked images. It will show the goto address in the status bar, but the cursor remains an arrow and clicking yields nothing.

  48. Kiyanwangon 16 Oct 2006 at 4:16 pm

    Hi everyone

    I encountered a problem with reflection 1.6, with reference to images that surrounded with anchor tags.  For example if you have:

        <a href="http://cow.neondragon.net/index.php/1343-Reflectionjs-16#"><img src="foo.gif" class="reflect"/></a>

    The the reflection alters the DOM model so that the structure looks like this:

        <a href="http://cow.neondragon.net/index.php/1343-Reflectionjs-16#"><div><img src="foo.gif" class="reflect"/></div></a>

    ( ive abridged the above!)

    The problem with this is that in Internet Explorer surrounding a div with an anchor tag isnt legal and as such the image is no longer clickable. Others have suggested adding an onclick event handler to the image but I dont like that for several reasons.

    I modified reflection.js locally so that it handles the case where an reflected image is surrounded by an anchor, ive pasted the source below in case anyone finds it useful. Basically I changed the getElementsByClassName function to check to see what the parentElement of the child is ( if your using internet explorer ), and as long as its an anchor I add a link attribute to the child.

    Then in the add function i use this link attribute to construct an anchor tag which is added to the dom inside the div tag. This appears to work.

     (apologies for just pasting it in like this I couldnt find a way to attach a source file, or email Cow ;) )

    Hope you guys find this useful.

     

    cheers

    Nadeem

     

     

     

    document.getElementsByClassName = function(className) {    var children = document.getElementsByTagName('*') || document.all;    var elements = new Array();          for (var i = 0; i < children.length; i++) {        var child = children[i];                        var classNames = child.className.split(' ');        for (var j = 0; j < classNames.length; j++) {            if (classNames[j] == className)             {                if (document.all && !window.opera)                {                    if( child.parentElement.tagName == 'A')                    {                                                        child.setAttribute('link', child.parentNode.getAttribute('href'));                    }                }                                elements.push(child);                break;            }        }    }    return elements;}
    
    var Reflection = {    defaultHeight : 0.5,    defaultOpacity: 0.5,        add: function(image, options) {        Reflection.remove(image);                doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity }        if (options) {            for (var i in doptions) {                if (!options[i]) {                    options[i] = doptions[i];                }            }        } else {            options = doptions;        }            try {            var d = document.createElement('div');            var p = image;                        var classes = p.className.split(' ');                        var newClasses = '';            for (j=0;j<classes.length;j++) {                if (classes[j] != "reflect") {                    if (newClasses) {                        newClasses += ' '                    }                                        newClasses += classes[j];                }            }
    
                var reflectionHeight = Math.floor(p.height*options['height']);            var divHeight = Math.floor(p.height*(1+options['height']));                        var reflectionWidth = p.width;                        if (document.all && !window.opera) {                /* Copy original image's classes & styles to div */                d.className = newClasses;                p.className = 'reflected';                                d.style.cssText = p.style.cssText;                p.style.cssText = 'vertical-align: bottom';                p.setAttribute('border','0');
    
                    var anchorTag = document.createElement('a');                anchorTag.setAttribute('href', p.link );                p.removeAttribute('link');                                            var reflection = document.createElement('img');                reflection.src = p.src;                reflection.style.width = reflectionWidth+'px';                                reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px';                reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')';                                d.style.width = reflectionWidth+'px';                d.style.height = divHeight+'px';                p.parentNode.replaceChild(d, p);                                anchorTag.appendChild(p);                d.appendChild(anchorTag)                                d.appendChild(reflection);                            } else {                var canvas = document.createElement('canvas');                if (canvas.getContext) {                    /* Copy original image's classes & styles to div */                    d.className = newClasses;                    p.className = 'reflected';                                        d.style.cssText = p.style.cssText;                    p.style.cssText = 'vertical-align: bottom';                                var context = canvas.getContext("2d");                                    canvas.style.height = reflectionHeight+'px';                    canvas.style.width = reflectionWidth+'px';                    canvas.height = reflectionHeight;                    canvas.width = reflectionWidth;                                        d.style.width = reflectionWidth+'px';                    d.style.height = divHeight+'px';                    p.parentNode.replaceChild(d, p);                                        d.appendChild(p);                    d.appendChild(canvas);                                        context.save();                                        context.translate(0,image.height-1);                    context.scale(1,-1);                                        context.drawImage(image, 0, 0, reflectionWidth, image.height);                        context.restore();                                        context.globalCompositeOperation = "destination-out";                    var gradient = context.createLinearGradient(0, 0, 0, reflectionHeight);                                        gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");                    gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options['opacity'])+")");                            context.fillStyle = gradient;                    if (navigator.appVersion.indexOf('WebKit') != -1) {                        context.fill();                    } else {                        context.fillRect(0, 0, reflectionWidth, reflectionHeight*2);                    }                }            }        } catch (e) {        }    },        remove : function(image) {        if (image.className == "reflected") {            image.className = image.parentNode.className;            image.parentNode.parentNode.replaceChild(image, image.parentNode);        }    }}
    
    function addReflections() {    var rimages = document.getElementsByClassName('reflect');        for (i=0;i<rimages.length;i++) {        var rheight = null;        var ropacity = null;                        var classes = rimages[i].className.split(' ');        for (j=0;j<classes.length;j++) {            if (classes[j].indexOf("rheight") == 0) {                var rheight = classes[j].substring(7)/100;            } else if (classes[j].indexOf("ropacity") == 0) {                var ropacity = classes[j].substring(8)/100;            }        }                Reflection.add(rimages[i], { height: rheight, opacity : ropacity});    }}
    
    var previousOnload = window.onload;window.onload = function () { if(previousOnload) previousOnload(); addReflections(); } 

     

     

     

     

     

  49. Adaon 17 Oct 2006 at 10:05 pm

    Kiyanwang !!!! THANJ YOU MAN…

  50. Leo Kennison 18 Oct 2006 at 2:05 pm

    I just downloaded reflection.js and it work…as long as I don’t give my images a margin/padding:

    <img src="samp.jpg" alt="Sample image" width=100 height=100 class="reflect rheight15" />

    img {
    float: left;
    display: block;
    margin-left: 25px;
    }

    Now my image is 25px left, but the reflection is still "0px to the left"…how comes, and what can I do about it?

  51. Leo Kennison 18 Oct 2006 at 2:08 pm

    Forgot to mention: not in IE, only in Opera/FF…

  52. Atomicon 26 Oct 2006 at 7:27 pm

    I love this script, but i cant get it to work on links that is to say. I have a picture in my website that is a link, but i cant make the image reflect, when i try i always get the same prob, it dosent work, and the image gets stuck to the left side of the page.

     

    Here is the script i was using

    <li><a href="http://cow.neondragon.net/index.php/1343-Reflectionjs-16#default" rel="ajaxcontentarea"><img src="ajaxtabs/start.png" class="reflect" border="0px"/></a></li>

     Why will this not work? How can I get it to work.

  53. Helmuthon 27 Oct 2006 at 10:08 am

    Hello,

    I found no other way to contact you. I just wanted to let you know that we have created a TYPO3 Extension to use your reflection.js in TYPO3.

    Here is the link to it 

    http://www.typo3wizard.com/en/articles/a-simple-extension-reflections-for-images.html

     Greetings

    Helmuth 

  54. Khloon 27 Oct 2006 at 1:33 pm

    Hi,

    Great work! Thanks for the link; I’ve added it to the local copy of the Reflection.js page but I haven’t uploaded it yet due to server problems. The link should be up soon :)

     

  55. Qureyoonon 08 Nov 2006 at 9:56 am

    hello there ^^ it’s a great script you have here ;)

    i’ll be using it on my blog :) and gonna make it prototyped :P

    oh,  and for some note you can make the code smaller for a byte or so :P on the if portion

            p.className = ‘reflected’;
            p.style.cssText = d.style.cssText = ‘vertical-align: bottom; ‘;

            d.style.width = reflectionWidth+’px’;
            d.style.height = divHeight+’px’;

            p.parentNode.replaceChild(d, p);
            d.appendChild(p);

    it can be put outside the if (before it) so it took only 1 times on the code ;) 

     

    *cheers* 

  56. Indyon 14 Nov 2006 at 5:10 am

    I’m trying to make a list of links with images in an <ul> and try as I might with display: inline; to get the images to line up in a row, all of my <li> take on block qualities. The images will stay in a row until the script adds the reflection at which point they form a column. Any suggestions?

    I looked at the README to figure out how all the sample images were in a row and saw that they had been put there with <tables> which is not an option that I would like to take.

  57. B Jon 15 Nov 2006 at 1:09 am

    This is exactly what I need. I’m working on a project called Psych Desktop and I needed a reflection engine. Thanks!

  58. Raghuon 30 Nov 2006 at 1:17 pm

    Great code man.. Thanks a lot!!

  59. Viper007bondon 02 Dec 2006 at 10:18 am

    Hmm, I can’t get it to work. The JS is loaded correctly (I think) and the class setting is there, but no reflection shows up. Any ideas?

    Example page: http://forums.finalgear.com/showthread.php?t=15110

  60. Viper007bondon 04 Dec 2006 at 1:47 am

    Hmm, I just noticed that it’s working fine in PMs (which uses the same template), but still not in threads. Weird. :(

  61. Alan Marchmanon 08 Dec 2006 at 7:24 pm

    When you use reflect.js on an image and place a text link directly under the image, IE7 can’t read the link at all, as if the reflect is covering it up. Trying to link the image no worky either. Just thought you’d like to know.

  62. Benon 08 Dec 2006 at 9:45 pm

    Hello,

    i can not seems to get the Link to the ZENPHOTO working, any ideas?

  63. Meltingiceon 13 Dec 2006 at 1:08 am

    Hey, first off… awesome script.  But for some reason my images which are in a table are being aligned with the left of the cell they are in instead of the center.  I am using the "text-align: center" bit of code to get them centered in their cell.  The images stay centered in IE7 with reflections but not in Firefox.  Any ideas as to why this is happening?  

  64. Geoffreyon 13 Dec 2006 at 2:18 pm

    Hello World,

    Your script still so nice. Thank you very much for it. I’m just having a little problem as the link isn’t working with ie when using your script.

    Do you have any suggestion? :)

    Regards,
    Geoffrey.

  65. Baz Lon 13 Dec 2006 at 5:26 pm

    Not sure if anyone has addressed this but:

     In IE, if the image is inside an <a href=""></a> and the reflection is added, the image is no longer clickable.  Is there anyway to over come this? I was trying to use this in a Gallery implementation for thumbnails.

  66. Tadaokon 15 Dec 2006 at 4:46 pm

    Hello FF user!

    to remove the border of linked image just modify the css

    use a universal selector *

    or

    create a style for class reflected 

    like this:

    .reflected{

    border:0; 

    }

     

    I´m trying a diferent solution… I´ll post here

  67. Tadaokon 15 Dec 2006 at 11:21 pm

    Great code Khlo

     

    using the tip of kiyanwang for IE

    I make some change in modigy for FF

     

    I think that solve the problem with tag <A>

    I think that is the problem in FF code (p.style.cssText)

    when use this… they clear older css inline. 

    bye!! 

     

    CODE 

     

    document.getElementsByClassName = function(className) {
        var children = document.getElementsByTagName('*') || document.all;
        var elements = new Array();    
      
        for (var i = 0; i < children.length; i++) {
            var child = children[i];                
            var classNames = child.className.split(' ');
            for (var j = 0; j < classNames.length; j++) {
                if (classNames[j] == className) 
                {
                    if (document.all && !window.opera)
                    {
                        if( child.parentElement.tagName == 'A')
                        {                                
                            child.setAttribute('link', child.parentNode.getAttribute('href'));
                        }
                    }                
                    elements.push(child);
                    break;
                }
            }
        }
        return elements;
    }
    
    
    var Reflection = {
        defaultHeight : 0.5,
        defaultOpacity: 0.5,
        
        add: function(image, options) {
            Reflection.remove(image);
            
            doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity }
            if (options) {
                for (var i in doptions) {
                    if (!options[i]) {
                        options[i] = doptions[i];
                    }
                }
            } else {
                options = doptions;
            }
        
            try {
                var d = document.createElement('div');
                var p = image;
                
                var classes = p.className.split(' ');            
                var newClasses = '';
                for (j=0;j<classes.length;j++) {
                    if (classes[j] != "reflect") {
                        if (newClasses) {
                            newClasses += ' '
                        }
                        
                        newClasses += classes[j];
                    }
                }
    
    
                var reflectionHeight = Math.floor(p.height*options['height']);
                var divHeight = Math.floor(p.height*(1+options['height']));
                
                var reflectionWidth = p.width;
                
                if (document.all && !window.opera) {
                    /* Copy original image's classes & styles to div */
                    d.className = newClasses;
                    p.className = 'reflected';
                    
                    d.style.cssText = p.style.cssText;
                    p.style.cssText = 'vertical-align: bottom';
                    p.style.border = '0';
                    
                    var anchorTag = document.createElement('a');
                    anchorTag.setAttribute('href', p.link );
                    p.removeAttribute('link');
                                
                    var reflection = document.createElement('img');
                    reflection.src = p.src;
                    reflection.style.width = reflectionWidth+'px';
                    
                    reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px';
                    reflection.style.filter = 'flipv
    progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+',
    style=1, finishOpacity=0, startx=0, starty=0, finishx=0,
    finishy='+(options['height']*100)+')';
                    
                    d.style.width = reflectionWidth+'px';
                    d.style.height = divHeight+'px';
                    
                    p.parentNode.replaceChild(d, p);
                    
                    anchorTag.appendChild(p);
                    d.appendChild(anchorTag)                
                    d.appendChild(reflection);
                    
                    
                } else {
                    var canvas = document.createElement('canvas');
                    if (canvas.getContext) {
                        /* Copy original image's classes & styles to div */
                        d.className = newClasses;
                        p.className = 'reflected';
                        
                        d.style.cssText = p.style.cssText;
                        p.style.verticalAlign = 'bottom';
                        
                        
                        
                        if(p.parentNode.tagName == 'A'){
                          /*<DIV> inheriting the css from <A>*/
                          var anchorTag = p.parentNode;
                          d.style.border = anchorTag.style.border;
                          d.style.margin = anchorTag.style.margin;
                          d.style.padding = anchorTag.style.padding;
                          
                          
                        
                        }
                          
                        var context = canvas.getContext("2d");
                    
                        canvas.style.height = reflectionHeight+'px';
                        canvas.style.width = reflectionWidth+'px';
                        canvas.height = reflectionHeight;
                        canvas.width = reflectionWidth;
                        
                        d.style.width = reflectionWidth+'px';
                        d.style.height = divHeight+'px';
                        
                        if(p.parentNode.tagName == 'A'){
                          anchorTag.parentNode.replaceChild(d, anchorTag);
                          d.appendChild(anchorTag);
                          anchorTag.appendChild(p);
                          d.appendChild(canvas);  
                        }else{
                          p.parentNode.replaceChild(d, p);
                          d.appendChild(p);
                          d.appendChild(canvas);
                        }
                        
                        context.save();
                        
                        context.translate(0,image.height-1);
                        context.scale(1,-1);
                        
                        context.drawImage(image, 0, 0, reflectionWidth, image.height);
        
                        context.restore();
                        
                        context.globalCompositeOperation = "destination-out";
                        var gradient = context.createLinearGradient(0, 0, 0, reflectionHeight);
                        
                        gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
                        gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options['opacity'])+")");
            
                        context.fillStyle = gradient;
                        if (navigator.appVersion.indexOf('WebKit') != -1) {
                            context.fill();
                        } else {
                            context.fillRect(0, 0, reflectionWidth, reflectionHeight*2);
                        }
                    }
                }
            } catch (e) {
            }
        },
        
        remove : function(image) {
            if (image.className == "reflected") {
                image.className = image.parentNode.className;
                image.parentNode.parentNode.replaceChild(image, image.parentNode);
            }
        }
    }
    
    
    function addReflections() {
        var rimages = document.getElementsByClassName('reflect');
        
        for (i=0;i<rimages.length;i++) {
            var rheight = null;
            var ropacity = null;
                    
            var classes = rimages[i].className.split(' ');
            for (j=0;j<classes.length;j++) {
                if (classes[j].indexOf("rheight") == 0) {
                    var rheight = classes[j].substring(7)/100;
                } else if (classes[j].indexOf("ropacity") == 0) {
                    var ropacity = classes[j].substring(8)/100;
                }
            }
            
            Reflection.add(rimages[i], { height: rheight, opacity : ropacity});
        }
    }
    
    
    var previousOnload = window.onload;
    window.onload = function () { if(previousOnload) previousOnload(); addReflections(); }
     
  68. Markon 18 Dec 2006 at 4:59 pm

    Is there a way to display, let’s say 5 images, of varying heights horizontally across the page so that they are aligned with the bottom of the div giving it an even reflection? As soon as I try to do this with the line-height property, the image and the reflection separate.

  69. Rohiton 24 Dec 2006 at 11:56 pm

    Thanks a lot for the script! This was way easier than the php alternative. I just had one problem. If I link an image i.e. <a><img /></a>, it draws a border around the original image. I tried adjusting by giving style="border-style:none;" around the table, but that doesn’t help.

    I am using 1.6 version 

  70. Jesse Con 28 Dec 2006 at 10:16 pm

    Great script - thanks for providing it. I managed to get into a Zen Cart build - but IE doesn’t seem to like it: it stretches the reflections to huge heights. Anybody have any thoughts as to why that might be - see it http://www.essereorganics.com/shop

  71. Smootheron 29 Dec 2006 at 2:58 pm

    If you are using reflection and moo.fx (aka "mootools") simultaneously, moo.fx works fine, reflection does not. Even not in the latest versions.

    To bypass this issue you need to modify your reflection.js:

     (1) Open reflection.js and replace the last line

    window.onload = function () { if(previousOnload) previousOnload(); addReflections(); }

    with

    window.addEvent('load',function () { if(previousOnload) previousOnload(); addReflections(); }); 
     
    In your document where you are going to use them, include mootools.js before reflections.js so the addEvent function is available.
     
    Greets, smoother 
  72. Greg Murrayon 02 Jan 2007 at 9:49 pm

    Hi,

     The license for Reflection.js says MIT style license but provides no links to a license. Is this license the one you are referring to?

    http://www.opensource.org/licenses/mit-license.php&nbsp;

  73. Khloon 03 Jan 2007 at 3:43 pm

    Greg: That is correct.

  74. Indyon 03 Jan 2007 at 9:31 pm

    Can someone please help me fix these two bugs:

    1) In IE, reflected images can’t be hyperlinked.

     2) In IE and FF, I can’t align the reflected image to the center if it’s within <p> tags.
     

  75. Stephanon 04 Jan 2007 at 9:43 pm

    Reflection seems to conflict with one of the java scripts i just implemented in my web site. I had a look into both scripts but i can’t figure out to make it work.

    Source of the other script: http://www.agilepartners.com/blog/2005/12/07/iphoto-image-resizing-using-javascript/

    Could you tell me how to solve this conflict?

    I am available by ICQ, MSN, YIM, AIM and mail to assist.

    Thanks in advance.

    Stephan

  76. Khloon 05 Jan 2007 at 9:37 am

    Stephan: Chances are another script is overwriting the onload event. Try using the onload="Reflection.add(this)" technique rather than class="reflect".

  77. Stephanon 05 Jan 2007 at 6:52 pm

    Sorry, I don’t get it.

    Should i use the onload attribute on any image i want to be reflected and delete the class definition?

  78. Khloon 05 Jan 2007 at 9:54 pm

    Yep.

  79. Prezentacje Multimedialneon 10 Jan 2007 at 10:02 am

    "To bypass this issue you need to modify your reflection.js: (1) Open reflection.js and replace the last line
    window.onload = function () { if(previousOnload) previousOnload(); addReflections(); }
    with
    window.addEvent(’load’,function () { if(previousOnload) previousOnload(); addReflections(); }); 
    In your document where you are going to use them, include mootools.js before reflections.js so the addEvent function is available."

    Can you speak more clearly? :/

  80. Yurion 22 Jan 2007 at 1:29 am

    Would anyone know how to modify the code a bit to ensure the reflection does not appear right below the image? I’d like to offset the reflection by a bit. Would be great if I could put the reflection exactly within a div I specify.

  81. Amiton 03 Feb 2007 at 9:39 pm

    are there any known issues displaying the reflection on IE6 standalone from evolt?? apparently it works perfectly in any other browser and platform (both mac and pc) but just not IE6.. 

    any ideas?? 

  82. Rasmuson 04 Feb 2007 at 1:16 pm

    As someone else has written (but is still unanswered).The image (and reflections) are aligned to the left after the js processing. This is done even if the image is aligned to the right or center.

    Does anyone has the solution for this? 

  83. Wortspielon 15 Feb 2007 at 8:51 am

    Hi,

    at first…nice work.

    I have a question. It is possible to set the reflection into the background?

    I have some images on the left side in a text area. Normaly the text are shown right from the image and under the image. If I use the reflection, the text is only under the image.

    So I put the image into a table, and the text are now shown right from the image and under the reflection. But if I have a big image, the reflection is also very big. So it will be very nice, when the text are schwon over x % from the reflection.

    thx 

  84. Mebleon 18 Feb 2007 at 10:12 am

    In IE, if the image is inside an <a href=""></a> and the reflection is added, the image is no longer clickable.  Is there anyway to over come this? I was trying to use this in a Gallery implementation for thumbnails.

  85. Joedmon 26 Feb 2007 at 1:35 pm

    I integrated reflection.js and I have to say that it really boosted the look of the sites i’m building.

    It has actually become a problem to know when to stop reflecting images.

    Great work! 

  86. Timon 28 Feb 2007 at 12:06 am

    where can i edit the class to add margins?

  87. Featurepics Imageson 02 Mar 2007 at 7:35 am

    Image Reflection" effect caught my eye today and I immediately decided to try it.

    I love it! Please check the implemantation of this script on our site.

    http://www.featurepics.com/Editorial/Image-Reflection-Special-Effect.aspx

     Thank you very much for sharing this wonderful script.

     

  88. Robert Wetzlmayron 03 Mar 2007 at 12:54 am

    Hi,

    I’ve packed reflection.js into a Textpattern plugin named "wet_wetfloor" and wrote a wrapper Textpattern template tag. Download and How-To are at my Textpattern plugin site

  89. Andreaon 07 Mar 2007 at 2:11 pm

    Is there a way to obtain a similar effect with text? It would be much more flexible. Think for instance to apply the effect to all first level headings.

    Since I’m not into javascript I don’t have an idea if it is feasible at all or there is some unsurmontable obstacle .

  90. Ralf Son 15 Mar 2007 at 9:48 pm

    Great script. I use it for my portal sites which have a header text based on the keyword. I write the header on the fly with php GD and this small javascript adds the reflection to it. But if you take a look at http://www.ilovetorrent.nl you see a bit of roughness on the edges in Firefox, Explorer seems to render it fine.

    Is it because you needto use steps by 10 pixel? For example 10,20,30 and not 25? 

  91. Brian Harrison 15 Mar 2007 at 11:10 pm

    I was having trouble with the images thats are links. and the code above works.

     I was also having issues in FireFox where if i centered the image, it would not stick after the javascript was executed.  Well i have found a homegrown solution that works for me.    this is the code i added.

    d.style.cssText = ‘text-align: center’;
    d.style.width = ‘100%’; 

     now let me explain what im doing here.  the container that is actually centering the image content has its width set, in my case its 130px, but it shouldn’t matter how wide it is. now i text-align center the new div and its works.

     Hope this helps someone out, or is able to permanently fix the script

  92. Brian Harrison 15 Mar 2007 at 11:26 pm

    sorry for the double post, i should have mentioned that i added:

    d.style.cssText = ‘text-align: center’;
    d.style.width = ‘100%’;

    to this if statement inside the else loop.

      if (document.all && !window.opera) {

    }else{
    d.style.cssText = ‘text-align: center’;
    d.style.width = ‘100%’;

  93. Jfkon 17 Mar 2007 at 6:03 am

    Hi.

    I’ve conflict with your reflection.js and with another js. I think it is the unload event.

    in reflection.js:

    var previousOnload = window.onload;
    window.onload = function () { if(previousOnload) previousOnload(); addReflections(); }

    In  3dcube.js file:
    window.onload=new Function("setTimeout(’movecube()’,delay)")

    When the 2 is on the same page, Reflection.js doesn’t work.

    Any idea?
    Thanks
    jfk

  94. Khloon 17 Mar 2007 at 11:11 am

    Load Reflection.js after you load 3dcube.js - Reflection.js doesn’t overwrite existing events. This applies to other JS files which set onload events.

  95. Joergon 19 Mar 2007 at 10:16 am

    I added this for my block.

    And this tool realy rocks! 

  96. Ramon Finckenon 19 Mar 2007 at 1:30 pm

    We moved domains

    http://phpbbinstallers.com/board/viewtopic.php?p=1910#1910

    is now >>

    http://phpbbinstallers.net/board/viewtopic.php?p=1910#1910

  97. Burton 19 Mar 2007 at 1:40 pm

    Hello

     

    First off all, i want to say this script is in 1 word fabulous.

    But i seem to have problems with the script in IE.

    look =>  http://users.pandora.be/highmoon666/test/reflexions/

    In IE it streches a lot. In FF it’s great.

    What can i do about this?

    Thanks.

  98. Emuleon 25 Mar 2007 at 3:03 pm

    hi
    Thank you very much for the quick answer. I’ll be honest with you, i actually don’t have the skill required to get exactly what you’ve just ask me to do. About this snippets of code, should i put it directly into the div id? img src? The ‘coverid’ should match the id of the div where my img src is?

    Enlighten me please… Merci beaucoup pour ta patience.

  99. Mr Tipson 27 Mar 2007 at 3:12 pm

    I love it…however, because the call to "addReflections" is on the onload there is a delay and the page jumps when the reflections get applied. I put the call on the bottom of the page, but it doesnt always work (ie. Load the page, some reflections show - refresh and then they all show). 

     Here’s what I put just above the </body>

    <script type="text/javascript">
    addReflections();
    </script>

    Any thoughts? 

  100. Flexmanon 29 Mar 2007 at 12:49 pm

    I use reflection and i works fine.

     

    the thing is my reflection move’s 1 px to the left  

     

    whats wrong ?

     

    http://www.flexflavour.nl&nbsp;

  101. Feeon 03 Apr 2007 at 12:25 pm

    I’m trying to make a list of links with images in an <ul> and try as I might with display: inline; to get the images to line up in a row, all of my <li> take on block qualities. The images will stay in a row until the script adds the reflection at which point they form a column. Any suggestions? I looked at the README to figure out how all the sample images were in a row and saw that they had been put there with <tables> which is not an option that I would like to take.

  102. Jimon 09 Apr 2007 at 7:13 pm

    i just thought i’d let you know that i’ve modifed reflection.js to include an option for setting a fixed height reflection in pixels, i’ve blogged about it on my blog here: http://zhuoqe.org/blog/2007/04/09/reflectionjs-modification-fixed-height-hehehe/

    hope you like part of the modifications enough to include them or similar things in future releases :)

  103. Christian Effenbergeron 16 Apr 2007 at 7:10 pm

    I’ve been inspired by your reflection.js and wrote a similar script called corner.js

    maybe you can imagine what it does…

    http://www.netzgesta.de/corner/
    http://corner.netzgesta.de/

  104. Khloon 16 Apr 2007 at 9:08 pm

    Hi Christian,

    That looks really really nice! It’s probably worth building a page with a little bit more information on it and then submitting it to a website such as Ajaxian! It looks like a really nice way to add image effects on the fly! 

  105. Giorgio Son 20 Apr 2007 at 11:33 am

    hey, i translated and modified your test page in order to explain to italian people how to use your reflection.js 

    there is your page

    http://www.ajaxcity.it/esempi/200704/reflection/

    and the article is @ http://www.ajaxcity.it homepage

     hope that’s ok 4 u..

    byee 

  106. Magnuson 21 Apr 2007 at 9:59 pm

    I love your JavaScript snippet; it creates the best image effect ever! I do have a problem do, I have my most of my images inside hide/show divs. When the display hides (display; block) the reflection disappear when the div is shown again. Do you have any idea what might be the problem?

  107. Mark De Silvaon 23 Apr 2007 at 8:53 am

    Hi is there a way to make this work for text? For eg:

    <h2 class="reflect rheight=20 ropacity=40"> TEXT HERE </h2>

    Thanks.

     

  108. Scott Mon 01 May 2007 at 4:22 pm

    This is awesome! I have been trying to do this to the images on my site for a long time. Thanks for providing this great script! I will tell everyone I know!

  109. Radeon 09 May 2007 at 1:52 am

    Hellooooouuu!

    Exellent script, works fine with few modifications that i read it bellow , http://www.beosms.com , this is link,  but i didn’t find anything about effects when you on linked image. You was written a little about that in readme file but i didn’t know how to do that. Where to find a discusion about effects, something like, when you are on link to have some glow effect or lightbox…

     

    Thanx a lot for script! 

  110. Erik Hansenon 12 May 2007 at 4:20 am

    I love this script!  Thanks!  One feature request if I may:

     Add an option for spacing between the original picture and the reflection.  A 5 pixel spacing may increase the quality of some images’ reflections.  I know the spacing is possible by adding that blank space to the bottom of the image, but it would be nice to be able to add the space dynamically.

     Thanks,

    Erik 

  111. Samon 12 May 2007 at 5:40 am

    First Off: This script is awesome works excellent.

    One thing though I have not been able to figure out in the documentation and in here. What if the image is aligned left / right and I want to float text around it ? The answer to that issue has yet to come .. Or it’s simply to late for me to find it. Reflections look great but the text is now displayed below the image ..  does anyone have a workaround besides tables ?

     

    Thank you

    Sam 

  112. Samon 12 May 2007 at 5:46 am

    I am sorry for posting once more: but I found the solution, after reading more closely through the code, perhaps someone else has use for it, too. 

    It’s actually very simple: pack the image into it’s own div and float that div, either left or right.  

  113. Michael Kellyon 18 May 2007 at 1:43 am

    Absolutely love the reflections!

    Thanks for your efforts.

    Unfortunately I’m having a slight issue in IE6…

    Firefox, Opera, Safari, IE7 all work fine.

    IE6, even thought the HTML code is still present I get a completely blank page. Well, the body background colour is there, but nothing else. Removing the reflections code fixes the problem…

    Any ideas?

    Thanks again,

    Mike 

  114. Judynaon 23 May 2007 at 3:50 pm

    Heya there!

    I’ve been browsing through your blog in hopes of finding your e-mail, but alas, I can understand why I can’t find it.

    I’m contacting you concerning this script, I was wondering what the terms of use.

    Please let me know - you may contact me at the address I used on here.

    Thanks!

    - Ju

  115. Judynaon 23 May 2007 at 4:05 pm

    Err, I meant : what the terms of use was*

  116. Khloon 23 May 2007 at 6:32 pm

    Hi there,

    It’s BSD-licensed so you can do whatever you want with it but all we ask is to  please leave the credits at the top :) 

  117. Kevinon 24 May 2007 at 7:18 pm

    I had this problem too…

    Hello

     

    First off all, i want to say this script is in 1 word fabulous.

    But i seem to have problems with the script in IE.

    look =>  http://users.pandora.be/highmoon666/test/reflexions/

    In IE it streches a lot. In FF it’s great.

    What can i do about this?

    —— SOLUTION ——-

    Took me a while but I got it. Add this line here….

    reflection.style.styleFloat = ‘left’;

    Put it below the (reflection.style.filter = …) line 

     In IE is seems the images need to float left or they wack out.

     

     

  118. Daltonon 10 Jun 2007 at 11:34 pm

    It would be interesting to allow the images to be rotated on the Y axis.

  119. Sentienceon 25 Jun 2007 at 10:29 am

    those looking for an answer to the alignment issue check out the following

     http://www.vbulletin.org/forum/showthread.php?t=114726&page=10 

     thanks for an awesome plugin and to other posters, your comments helped me fix the linked image bug

     ~Sentience 

  120. Matton 25 Jun 2007 at 4:26 pm

    Having trouble integrating this with litebox 1.0. Litebox is a trimmed down version of Lightbox 2.0. I’ve modified the litebox js to increase the window size and that works no problem. My issue is when I add..

    Reflection.add($(’lightboxImage’), { height: reflectHeight, opacity: reflectOpacity });

    to the beginning updateDetails function. When I do this, no image is displayed at all in the lightbox. Ideas?

  121. Eamonnon 26 Jun 2007 at 5:21 pm

    Have you had any reports of conflicts between Reflectiosn.js and the Google Maps API. I can’t seem to get the two to operate correctly on the same page. The debugger shows the error occurring in the Google Maps obfuscated javascript but it only happens when the reflections code is in use on the same page and so i suspect that that is the source. Any help would be greatly appreciated.

  122. Nilson 26 Jun 2007 at 8:16 pm

    I really love what this script does but I am unable to get it to work on my site.  I manage two sites at work (same host) and it works on one but not the other.  I uploaded reflection.js to the root of the site, referred to it in the <head>, as instructed, then added the reflect class to a couple of images to try it out.  Nothing happened.  I’m on a mac but I checked it out in IE, FF and Safari and never saw it.  Any suggestions would be greatly appreciated.

    Here’s the culprit page: Home Simulator Accessories

    I’ve tried it on simpler images on other pages of the site but still no luck.  Any suggestions? 

    PS- I tried putting the .js reference in every location of the <head>.  I’ve also tried moving the script source to different areas of the site and changing the reference.  No luck.

  123. Chad Granton 30 Jun 2007 at 4:48 am

    I really like your plugin. Did you investigate using any skewing of the reflection ?

     Like a traditional reflection : http://www.tipclique.com/tutorial/photoshop/photoshop-reflections/

  124. Annon 06 Jul 2007 at 10:18 pm

    Great script, it works really fine. Thanks!

  125. Kyleon 07 Jul 2007 at 12:05 pm

    Are you using Javascript to do a XmlHttpRequest call and setting the innerHTML based on the response of the request? 

  126. Rob Wuhrmanon 11 Jul 2007 at 1:35 am

    Very nice.  Thanks.

    Here’s a possible issue - When an image is left aligned and the reflection class is applied to it, text no longer wraps itself around the image.  Instead the text drops to below the image.  Tested in IE7.

  127. T Dragon 2000on 14 Jul 2007 at 6:45 pm

    Hello, 

    I want reflection.js for VIDEO object(object tag or embed tag).

    Is there the making plan? I ask for making by all means.

     The reflection part should move, too.

     

    English is sorry with poorness.

     

  128. Ryanon 19 Jul 2007 at 4:50 am

    Does this work on text?

  129. Tyler Menezeson 26 Jul 2007 at 8:36 pm

    I created a reflect.js modification for the E-Blah bulletin board system. It’s available at http://www.tylerm.info/reflectjs.v2m (though if you’re going to link to it, I’d appriciate it if you could mirror it here, my server’s pretty cheap, I don’t know how it’d take to the extra bandwidth.)

  130. Laurenton 30 Jul 2007 at 3:15 pm

    excuse my english, i’m french

    In joomla with IE7 with composant we have stack over flow because we have always window.onload always egal 0 why don’t you put for the last line of the script only :

    window.onload = function () {addReflections()};

    when I put only this line without

    //var previousOnload = window.onload//window.onload= function () { if(previousOnload) previousOnload(); addReflections(); }

    the script run correctly with IE7 and firefox

    Best regards

  131. 27604209983045225773on 01 Aug 2007 at 4:57 am

    Thanks for the reflection script. Definitely a cool effect which i will use in the future in my design works and portfolios. Again thanks for sharing!

  132. Johnny Scoreson 01 Aug 2007 at 4:58 am

    Thanks for the reflection script. Definitely a cool effect which i will use in the future in my design works and portfolios. Again thanks for sharing!

  133. Navinon 01 Aug 2007 at 11:28 pm

    Check out my attempt, it does not use the canvas object.

    http://n.vain.in/reflect.html has a client side javascript implementation of reflection

    Really small code size, and needs no canvas.

     

     

  134. Banaon 04 Aug 2007 at 12:34 am

    Great code man.. Thanks a lot.

  135. Banaon 04 Aug 2007 at 12:35 am

    thanks.

  136. Johnon 06 Aug 2007 at 8:47 am

    This is cool thanks  ;)

  137. K-Neton 07 Aug 2007 at 11:26 pm

    Changed the onload to window.onload and then included reflection.js. Works like charm, thank you!

  138. Ramiroon 08 Aug 2007 at 5:45 pm

    Will it be that somebody can help me?

    I’m not a programmer, I’m photographer trying to do my own site (www.rmpires.com).
    I found this script perfect for me, but, it don’t work.
    I’m using in my main page the script "CMotion Image Gallery" (http://dynamicdrive.com/dynamicindex4/cmotiongallery.htm) and "Lightbox image viewer" (http://www.dynamicdrive.com/dynamicindex4/lightbox2/index.htm) and I would like the thumbs to have the reflection, but, it doesn’t work according to the code below. Can somebody help me? Thank you!

    ———-
    <html>
    <head>
    <title></title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />

    <script type="text/javascript" src="js/reflection.js"></script>
    <script type="text/javascript" src="js/prototype.js"></script>
    <script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
    <script type="text/javascript" src="js/lightbox.js"></script>

    <link rel="stylesheet" type="text/css" href="css/gallerystyle.css" />
          
    <!– Do not edit IE conditional style below –>
    <!–[if gte IE 5.5]>
    <style type="text/css">
    #motioncontainer {
    width:expression(Math.min(this.offsetWidth, maxwidth)+’px’);
    }
    </style>
    <![endif]–>
    <!– End Conditional Style –>

    <script type="text/javascript" src="js/motiongallery.js"></script>

    <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="css/main.css" type="text/css" />
    <txp:wet_wetfloor_script />
    </head>
    <body>
    <div id="pagewidth" >
        <div id="header" > </div>
                <div id="wrapper" class="clearfix" >
                <div id="maincol">
                
                <div id="motioncontainer" style="position:relative;overflow:hidden;">
        <div id="motiongallery" style="position:absolute;left:0;top:0;white-space: nowrap;">

        <nobr id="trueContainer">
        
        <a href="images/image01.jpg" rel="lightbox[roadtrip]"><img src="thumbs/thumb01.jpg" class="reflect" alt="" /></a>
        <a href="images/image02.jpg" rel="lightbox[roadtrip]"><img src="thumbs/thumb02.jpg" class="reflect" alt="" /></a>
            <a href="images/image03.jpg" rel="lightbox[roadtrip]"><img src="thumbs/thumb03.jpg" class="reflect" alt="" /></a>
        <a href="images/image04.jpg" rel="lightbox[roadtrip]"><img src="thumbs/thumb04.jpg" class="reflect" alt="" /></a>
        <a href="images/image05.jpg" rel="lightbox[roadtrip]"><img src="thumbs/thumb05.jpg" class="reflect" alt="" /></a>
        
        </nobr>

    </div>
    </div>
                
                </div>
    </div>
        <div id="menu" > </div>
        <div id="footer" ></div>
        </div>
    </body>
    </html>

     

     

  139. Benjamin Mon 10 Aug 2007 at 12:06 am

    Weirdly enough, I am having exactly word-for-word the same problem as Ramiro.  Here is the symptoms:  if I create a gallery using your script (reflection.js), the lightbox vs 2.0 (not 2.02) script, and the cmotion DHMTL scrolling gallery script, I end up with a reflection sitting to the right of the original image.  You can see the scripts at the following webpages:

    http://www.huddletogether.com/projects/lightbox2/

    http://www.dynamicdrive.com/dynamicindex4/cmotiongallery.htm

     

    I would love if someone could help me to fix this problem.  I know some html, but not enough JS to fix this.

    Best,

    Ben 

  140. Jon 15 Aug 2007 at 10:23 am

     

    This is seriously slick – thank you for an awesome application. Are you able to get it to work on plain text? I suppose that may be difficult – but with some artistic talent, it could look quite nice. Especially if you want to have menu items, for instance, with some shadowing on a background or something. Keep at it – this application is brilliant. Hope to see some improvements soon, as well!

    Just to let you know, 1.6 fixed some issues I was having in ie for some reason… not sure why, but it’s working great now.

  141. Nigelon 17 Aug 2007 at 11:21 am

    Thanks for a great script bar a few IE errors its perfect.

    Im sure you already know but the onmouseover events to vary the reflections opacity does not work in IE, is there any way around this? 

  142. Ricardoon 20 Aug 2007 at 3:16 pm

    i can´t download the script. Message…

    404 - Not Found

  143. Griffinon 20 Aug 2007 at 4:46 pm

    I use the modified version from Kiyanwang, because I need the link option for my site. The problem is: IE is opening the linked site in the same window. The target="_blank" command in the link tag has no effect! Firefox and Opera do it correctly. Has anybody a idea how can solve this problem? Unfortunately I’m a JavaScript flopper

    This seams to be a small thing, but I can not use the script if that’s not working , so please help me

    Regards,

    Carsten 

     

  144. Johnon 21 Aug 2007 at 5:57 pm

    Is the reflectomatic service broken?

    I’m getting a 404 from http://cow.neondragon.net/stuff/reflection/ 

  145. Erlloon 26 Aug 2007 at 10:32 am

    OMG

  146. Neilon 29 Aug 2007 at 4:47 pm

    I still can’t get images to work as links?

    Does anyone have a definitive answer please?!

  147. Mark Stamon 30 Aug 2007 at 10:14 pm

    I have a question, i use this reflection tool on my site:

    http://www.you-can.nl

    but i have a problem that all the reflections are 1 maybe 2 px to the left in
    FF and to the right in IE….

    does anyone knows my problem? 

  148. Bobon 02 Sep 2007 at 7:21 pm

    This sure looks like a wonderful product … if only I could get it to work. The instructions are not very helpful to someone like me who doesn’t work with java script much. About all I can do with scripts is cut and paste. 

    I have this:
    <script type="text/javascript" src="reflection.js"></script> in my html header and I added a class="reflect" in my image src. But where, exactly, is the script itself supposed to go? The instructions only say to add it to your website. No matter where I put the script, it only renders the file’s text on my web page, no reflections.

    Can you provide a clue for the clueless?

    Thanks! 

     

     

  149. Mark Stamon 02 Sep 2007 at 11:10 pm

    download the reflection.js and put that file into the main directory of your site then it works

  150. Bobon 04 Sep 2007 at 4:57 pm

    Mark - 

    No, actually that doesn’t work. I put the reflection.js script into my main directory, but no reflections on the images.

    I’ve placed the reflection.js script into my html header and got a reflection once in Firefox, but it was way off in IE7. I could not produce the reflection again in Firefox, instead the browser showed a syntax error. 

    Bob 

  151. Khloon 08 Sep 2007 at 11:17 pm

    Reflection.js v1.7 is here.

    Thus this blog entry will be locked. Please post all future support queries here

Trackback URI | Comments RSS

Leave a Reply