Reflection.js version 1.5

May 19th, 2006

I’ve just released an big update to reflection.js - 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?

This is a huge update. It fixes many of the bugs and issues that users have been experiencing with previous versions and adds the much-requested ability to set the opacity and the height of the reflection. It also adds scriptable reflection so you can have your reflections repond to user events - for example have the reflection get brighter when the mouse is moved over it. It also works a lot better with scaled images.

As this fixes quite a few bugs, it’ll may also change the look of some of the reflections on your site. Some stuff such as the wholeimage class has been removed. So make sure everything works properly before you upgrade.

Demo

See a demo of reflection.js 1.5 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. Check out the new testsuite too!

Thank you!

I should thank everybody for their feedback and help getting us towards version 1.5. In particular Josh who pulled his hair out trying to fix a problem with reflection of landscape images in Safari! 

Related Posts

  1. Reflection.js 1.6
  2. Reflection.js 1.9
  3. Reflection.js 1.7
  4. Reflection.js 1.8
  5. Reflection.js 1.0

114 Responses to “Reflection.js version 1.5”

  1. Rohan Dhruvaon 21 May 2006 at 9:12 pm

    The reflections script does not work on konqueror[1] .. could you please work on it when you hav the time ? The effect is really very nice looking, but it’d be great if it worked on konqueror. Thanks.

    [1] - http://konqueror.kde.org/

  2. Khloon 21 May 2006 at 9:31 pm

    Hi!

    Thanks for the feedback. To my knowledge, KHTML (Konqueror) does not support the <canvas> tag which makes it all possible. Safari which is based on KHTML supports it. If this is backported or <canvas> is added to Konqueror some way or another, it should work in Konqueror.

  3. Aaronon 21 May 2006 at 9:51 pm

    Congratulations, you’ve been boinged!

    Great work on this. It’s what all great apps should be: simple, elegant and nice to look at. I’m inspired to incorporate it into my designs!

  4. Khloon 21 May 2006 at 10:35 pm

    Lovely! Thanks for the info

  5. Pjon 21 May 2006 at 10:43 pm

    I was impressed! I couldn’t see anything using Firefox, though, so I couldn’t see the relection effect until I loaded your page in Internet Explorer.

  6. Kameronon 21 May 2006 at 10:46 pm

    Just thought you’d like to know this crashes FireFox 1.5.0.3 on MacOS X 10.4.6.  Works like a charm in Safari and on my Windows machine, though.  The crash is probably a FireFox bug… :)

    Thanks! 

  7. Khloon 21 May 2006 at 11:00 pm

    Hi,

    Please make sure that your using Firefox 1.5. I notice that a lot of people still use Firefox 1.0 probably due to the fact the Update notification in Firefox 1.0 isn’t particularly good. You will need Firefox 1.5 to use this tool as it uses Canvas which only appeared in Mozilla 1.8.

    Regarding the Mac issue, I don’t have a mac so I can’t reproduce. If anyone else has a Mac and could try it out, it’d be appreciated. It works fine on Firefox 1.5.0.3 Windows so not sure what could be causing issues for Mac. 

  8. Uaretroublesomeon 22 May 2006 at 1:00 am

    this is sweet..thank you!

  9. Lkon 22 May 2006 at 1:04 am

    Script is on the server, in the public_html directory

    Script is included in the head of the document

    reflect is added to the image class … and nothing. Firefox and IE … nothing. It’s broken.  It doesn’t work. It sucks. I want 30 minutes of my fucking life back

    0

  10. Bonon 22 May 2006 at 1:13 am

    Lk you are arrogant and rude. If you can’t get it to work then you are obviously doing something pretty stupid. Are you sure you’re not using FrontPage Express to edit your web pages?

    Cow - if that’s your real name - this is an excellent script and it works like a charm. Thanks for taking the time to share it with the community!

  11. Nkon 22 May 2006 at 3:57 am

    Hi … great work!!…

    I noticed that it dosent work when there are preloaded images on the page. It would be great if you could generate a fix for that.

    Thanks… I really love this

  12. Andrewon 22 May 2006 at 4:28 am

    Here’s how to apply it to a phpBB forum:

    1. Uploaded reflection.js into / directory
    2. Opened viewtopic.php, went to line 849 where it says

    Code:
    $poster_avatar = ( $board_config[’allow_avatar_upload’] ) ? ‘<img src="’ . $board_config[’avatar_path’] . ‘/’ . $postrow[$i][’user_avatar’] . ‘" alt="" border="0" />’ : ”;


    and changed it to

    Code:
    $poster_avatar = ( $board_config[’allow_avatar_upload’] ) ? ‘<img src="’ . $board_config[’avatar_path’] . ‘/’ . $postrow[$i][’user_avatar’] . ‘" alt="" border="0" class=" class="reflect rheight33" />’ : ”;

          There are also 2 other entires right around there and you do the same thing.

    3. Opened overall_header.tpl and put this directly above another <script > tag

    Code:
    <script type="text/javascript" src="/reflection.js"></script>

     If you want it to display in profiles and such, you got some more pages to edit.  But if you can apply it like I showed you, you should be able to also apply it elsewhere.

  13. Dhtml Guyon 22 May 2006 at 5:35 am

    http://dynamicdrive.com/dynamicindex4/reflect.htm

     

    here is an older one for comparison - it WAVES/ Animates only for IE

  14. Markon 22 May 2006 at 6:11 am

    Found this article on digg. This was just something I was looking for my site! Thanks! :)  

  15. Jarfilon 22 May 2006 at 8:12 am

    Doesn’t work on Linux.

    Checked with:

    • Firefox 1.5.0.3
    • Konqueror 3.5.2
    • Opera 8.51
    • MSIE 6

    On Windows it works, on Linux it doesn’t. Just like that.

  16. Khloon 22 May 2006 at 9:26 am

    Lk: The chances are something else is probably overwriting the window.onload event.

    Nk: Try using the Reflection.add() event as documented in readme.html. If you provide a DOM element, it should add a reflection to it.

    Dhtml Guy: Looks pretty cool! Thanks!

    Jarfil: I believe it worked on Firefox/Linux last time I checked. I wonder if this could be to do with some kind of graphics library. 

     

  17. Dr00on 22 May 2006 at 11:54 am

    yo, just incase you are interested, i implemented reflection.js on my site and its smooth - dr00.com

    thanks a bunch 

  18. Chris Woodson 22 May 2006 at 12:50 pm

    To confirm a comment posted above: it does _not_ work in Firefox 1.5.0.3/Universal in Mac OS X 10.4.6/intel. In fact, Firefox crashes consistently just trying to load the page at http://cow.neondragon.net/stuff/reflection/ . Granted, this is clearly a Firefox bug since there should be _NO_ code that can crash the browser, but it’s worth pointing out. It also only barely works in Safari 2.0.3 on the same platform - did somebody mention that the ripples are animated? That’s not evident anywhere that I’ve seen so far in either browser.

  19. Khloon 22 May 2006 at 2:10 pm

    No, there are no ripples and they are not supposed to be animated. That comment was linking to a demo of an older reflection script on Dynamic Drive from the first DHTML revolution

    It seems like quite a few people have commented about a crash on Firefox Universal Binaries. It works fine on the PPC build. I’d really appreciate it if someone who experiences this issue could submit a bug to Mozilla as they can provide stuff like UA and crash logs. 

  20. Khloon 22 May 2006 at 2:14 pm

    Thanks for the instructions Andrew! I’ve added it to the implementations list.

  21. Dgon 22 May 2006 at 11:51 pm

    Khlo - Nice script, I was installing Wet-floor plugin. But luckily yesterday, I came across your script.I have immediately implemented this and also wrote about on my blog.

    http://www.roks.xmgfree.com/blog/2006/05/22/add-reflection-to-images-in-your-site/

  22. Christian Readyon 23 May 2006 at 3:12 am

    This is a truly amazing script.  Well done!

    I did notice one thing, though.  When I apply the reflect class to an image that is wrapped in an <a href="…> element, the link does not appear to work in MSIE 6. It does work in Firefox 1.5 just fine, though (figures :).

    Anyway, great work and I plan to make use of this great script!

    Christian 

  23. Roderickmon 23 May 2006 at 7:34 am

    There’s now a theme for the Zenphoto simple photo gallery that uses your Reflections.js. It was very easy — only took a minute to link in your javascript and class tag! See the ZenPhoto Theme Directory.

  24. Alexon 29 May 2006 at 4:41 pm

    Man … this is awesome !!!!!! I was fascinated by Apple UI’s reflection and started do it on my work , but using photoshop … now it;s on the fly !!!

    Cool , THX !!

  25. Jasonon 15 Jun 2006 at 8:29 pm

    Thanks for the script! Really great idea!

    I thougt I’d mention a few problems I have had (using Firefox 1.5).

    1. if the HTML body tag has an onload like this:
      onload=”
      your script does not run addReflections()
    2. if I have a series of img tags all side-by-side (each one has a link on it with an href and onclick) a BR-type of line break is added after each image when your reflection script does its thing 
  26. Khloon 15 Jun 2006 at 9:47 pm

    Hi,

    1. The onload="" argument will overwrite reflection.js’ onload event. You should include reflection.js after the <body> tag or load your events using Javascript e.g. window.onload = myOnloadEvent; in the head portion of your webpage which is the recommended method of using onload events anyway.
    2. This is because the div it replaces it with is a block element. You could either float the images or use a table to get around this.
  27. Alainon 17 Jun 2006 at 12:35 am

    I’ve been having an issue with IE, where the reflection seems to extend down a lot farther than the actual image. The image is contained within a table, and doesn’t have any link tags or anything. It does have a rowspan for the cell, but thats about it. Anyone have the same issue?

  28. Alainon 17 Jun 2006 at 1:26 am

    Update: It seems that the duplicate image created in the reflection script doesn’t copy the set dimensions of the target image.

    For example:

    I have an image that 600×500 but within the image tag, I set the dimensions equal to 150×150.

    In Internet Explorer, the reflection script will create a 600×500 reflection and not the 150×150 size. So though you have a smaller image, the reflection is gigantic.

  29. Alainon 17 Jun 2006 at 4:15 am

    There is still the issue with the

  30. Alainon 17 Jun 2006 at 4:17 am

    oops. Sorry. It didn’t like my open “href” tag.

    Anyways, thats another problem with the code. In Internet Explorer, the “href” link that surrounds the image won’t work when its reflected.

    IE only.

  31. Khloon 17 Jun 2006 at 12:02 pm

    Hi,

    Yes - there are issues with reflection of scaled images in IE due to certain limitations in the way it’s reflected. I’ve been exploring ways to get around it but so far nothing yet.

    I guess IE doesn’t like having <div> tags nested in an <a href>. Hmm… 

  32. Niels Leenheeron 19 Jun 2006 at 10:31 am

    Thanks Khlo,

    The script looks great! I did modify one thing though. When using this script in Opera 8.5 it moved one of my images around. I know it won’t add a reflection, but it should changed anything else either.

    So I added a new if() statement to check if canvas support is present:

      if (document.all && !window.opera) {     … ie code path …  } else {     var canvas = document.createElement(’canvas’);     if (canvas.getContext) {       … canvas code path …     }  }

    Next I moved the code that copies the styles from the images to the divs:

       /* Copy original image's classes & styles to div */   d.className = newClasses;   p.className = ‘reflected’;                       d.style.cssText = p.style.cssText;   p.style.cssText = ‘ ‘; 

    This code used to be executed always. In other words, even if the browser did not support reflections the styles and classes were stripped from the image. I’ve moved the code above to inside the ‘IE code path’ and also copied it inside the ‘canvas code path’. The result is that this code is only executed on IE, or if the browser actually has Canvas support.

    This solved my problem. 

  33. Khloon 19 Jun 2006 at 12:07 pm

    Hi,

    Thanks for letting me know about the issues! I’d like to modify the script to include your changes; hope you don’t mind!

    Khlo 

  34. Niels Leenheeron 19 Jun 2006 at 4:19 pm

    Hi Khlo,

    Of course I don’t mind. Go ahead.

    Niels 

  35. Simone Tomasellion 21 Jun 2006 at 11:22 am
    Hi! great work!
    Maybe you can help me more...:-)
    I copied the apple aperture style for my photo group website http://www.polaser.org
    If you look at the pages, you'll notice i made (by photoshop) this nice effect.
    I would like anyway to automate it (e.g. within asp pages for a thumbnail view or similar) and your script is wow!
    So i made a big transparent png with the black part up and the transparent on bottom, and i overlayed it with a div (with bigger z-index)
    I am not so good at js, so i found out that using a table cell and putting the exact size of the underlying image (already reflectionED) it comes out good.
    What is not good is that i have to manually put the size for each image... so i ask you: how would it be possible to add to your js script so that dimensions (and maybe positions) are detected?
    you can look the result here:
    http://www.simont.org/public/mirror/mirror.htm
    snippet of layer code is just this: 
    <tr><td> <div id="Layer1" style="position:absolute; z-index:5;"><img src="mask.png" width="400" height="288"></div><img id="refl" class="reflect ropacity33 rheight33" src="ph0008.jpg" width="400" height="288"></td>  </tr>
    thanks in advance
    Simone - Italy
  36. Khloon 21 Jun 2006 at 11:26 am

    Hi,

    Yes, you can change the default height and opacity of reflections. Right below this line:

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

    Add the following:

    <script type="text/javascript">Reflection.defaultHeight = 1/3;Reflection.defaultOpacity = 1/3;</script>

    You then shouldn’t have to specify ropacity33 and rheight33 in each image. 

     

  37. Simoneon 21 Jun 2006 at 1:36 pm

    Thanks for the hint, but maybe i didn’t explain well my problem.

    i want a way to automate my overlaying with the mask.png file, but not having to set his w and h (same as the image to which i apply reflection).

    Is any way to built in support for an overlaying image, i mean to scale it exactly over the image i am reflectioning?

    sorry for bothering…

    cheers

    simone

  38. Khloon 21 Jun 2006 at 2:05 pm

    Erm, you could try reflecting the mask too - not sure how well it’d work though.

    The best thing to do would probably to put mask.png in the actual image. 

  39. Simoneon 21 Jun 2006 at 3:01 pm

    Thanks.. and have a look here, if you want tell me what you think..

    http://www.polaser.org/cercautore.asp

    (press F5 for a new picture every time)

    cheers Simone

  40. Khloon 21 Jun 2006 at 5:09 pm

    Beautiful! Love the artwork!

  41. Jim Kerron 25 Jun 2006 at 6:54 pm

    Any chance of having the pre-loaded images problem fixed? My page has lots of pre-loaded images and, as mentioned, this breaks reflection.js. I have no clue what a dom element is or how to fix it via the coding solution mentioned above without a step-by-step tutorial.

  42. Khloon 25 Jun 2006 at 7:57 pm

    I wasn’t aware of any breakage with preloaded images; you simply have to call Reflection.add() on the image as you can’t rely on the reflect attribute (it only runs onload of window). Just add onload="Reflection.add(this)" to all of your images when you add them using JS.

  43. Spenceon 26 Jun 2006 at 12:21 am

    Hi there-

     First off, great job on reflections!  I’m using it on my photoblog (http://rig.hteo.us) and absolutely love it. 

    I beleive I discovered a bug in version 1.5.  When reflecting a GIF file with transparencies, the math to invert a rounded image is backwards.  To see an example of what I’m talking about, check out this screen-shot.  (http://www.hteo.us/public/relfection_broken.jpg).  Notice how the curves are inverted?  If you want to play with the source image you can find it here: http://www.citlink.net/~spencey/nav-yesterday.gif 

     Cheers,

    Spence 

  44. Spenceon 26 Jun 2006 at 12:25 am

    Me again– Noticed that the problem only occures when the background is NOT #000.  e.g., it happens with #333.  –Spence

  45. Khloon 26 Jun 2006 at 9:29 am

    I think there is an issue in Firefox 1.5 with reflected images with transparency. AFAIK it’s a browser bug.

  46. Jonon 05 Jul 2006 at 11:13 am

    Where do I modify the Lightbox code to add reflections to the larger image?

    Thanks!

  47. Khloon 05 Jul 2006 at 11:43 am

    I can’t speak about where to add it - you will have to use the Reflection.add() function though. You could try onload="Reflection.add(this)" in the image which gets popped up in the Lightbox but as I don’t know the Lightbox code I can’t give you an exact location.

  48. Jonon 05 Jul 2006 at 12:00 pm

    I did look and there is a function call showimage(), but to be honest I couldn’t see where to add it.  Here is the link to the lightbox code Lightbox Source Hope you have better luck than me! Thanks a lot

  49. Jonon 05 Jul 2006 at 12:39 pm

    I found code where it pops up the image in HTML it generates and thought to add the class="reflect" to the HTML generation which it did but I found that it changed it to "reflected" and so didn’t create the reflection.

     

    var objLightboxImage = document.createElement("img");
            objLightboxImage.setAttribute(’id’,'lightboxImage’);

            objLightboxImage.setAttribute(’class’,'reflect’);

            objImageContainer.appendChild(objLightboxImage); 

  50. Khloon 05 Jul 2006 at 3:39 pm

    After the last line try adding:

    Reflection.add(objLightboxImage);

    class="reflect" doesn’t work with images which do not exist when the page was loaded (e.g. lightbox images) 

  51. Jonon 05 Jul 2006 at 4:39 pm

    Same problem unfortunately. It creates a class for the image called "reflected"

  52. Khloon 05 Jul 2006 at 4:58 pm

    I looked through the code; it looks to me as if the lightbox creates the divs for the images and links once the first time and then changes the source URLs when you click on a link.

    Find the changeImage function.

    After:

    imgPreloader.src = imageArray[activeImage][0];

    Add:

    Reflection.add(imgPreloader);

    Hope this helps! 

  53. Jonon 05 Jul 2006 at 5:05 pm

    I tried something similar earlier but tried to add the class name to it. That didnt work and unfotunately your suggestion hasn’t worked. It doesn’t error but it doesn’t do anything either!

  54. Khloon 05 Jul 2006 at 5:08 pm

    Have you got a demo? Without actually looking at it and what it does it’s very hard to try and make something work and I really don’t have the time to create a webpage and work out how to install a lightbox on it at the moment.

  55. Jonon 05 Jul 2006 at 5:12 pm

    http://netvibes.dreamhosters.com/jc/lightbox202/

    Thanks 

  56. Khloon 05 Jul 2006 at 5:54 pm

    Hey,

    I explored it a little more - Lightbox calls updateDetails() when the image has loaded into the lightbox. So if you add this to the top of the updateDetails function, it’ll show a reflection:

    Reflection.add($('lightboxImage'));

    However, the lightbox does not resize to allow space for the reflection so you’ll have to modify the code which changes the height of the lightbox. I suggest adding this to the resizeImageContainer function:

    imgHeight = imgHeight*1.5;

    1.5 is used because you have the original height of the image plus the height of the reflection which is by default 50%. If you change the height of the reflection, you’ll have to change this value.

    HTH. 

  57. Jonon 05 Jul 2006 at 6:11 pm

    Thanks very much! You da man!

     

    Slight problem!! It doesn’t seem to work in Firefox 1.5.0.4.

    Any ideas?

  58. Khloon 05 Jul 2006 at 6:31 pm

    It worked for me in Firefox 1.5 when I modified the script on my computer. If you can post a URL demo that’d be helpful (I presume the URL above doesn’t have the fixes)

  59. Jonon 05 Jul 2006 at 6:44 pm

    Have uploaded to that URL!

     

    Also added code to remove the reflection in between transitions.

     

    The reflection is added in Firefox but the height doesn’t seem to be increasing for the caption cox. All ok in IE surprisingly

  60. Jonon 05 Jul 2006 at 6:50 pm

    I’ve fixed it!

    You need to add *1.5 in the resizeImageContainer to this line

     

    if(!( hDiff == 0)){ new Effect.Scale(’outerImageContainer’, this.yScale, {scaleX: false, duration: resizeDuration, queue: ‘front’}); }

    TO

    if(!( hDiff == 0)){ new Effect.Scale(’outerImageContainer’, this.yScale*1.5, {scaleX: false, duration: resizeDuration, queue: ‘front’}); } 

  61. Khloon 05 Jul 2006 at 7:16 pm

    Ah, beautiful! Looks great too!

    I wonder if you might want to consider releasing the modifications so other users could grab a Reflection-enabled Lightbox or (with permission) I could host the modified script on this server. If you want to stick the file on your own site I can also link to that.

    Cheers! 

  62. Jonon 05 Jul 2006 at 7:54 pm

    Feel free to download the scripts from here

    Lightbox
    Reflection

    At the top of the Lightbox script I have set a Global variable that you will need to change depending on the height of the reflection.

    I should think you could modify it further to set the opacity etc on the Reflection.add method.

    Look for the  updateDetails function and modify this Reflection.add($(’lightboxImage’));  to try the opacity variable. If it works please let me know!    

     
    Thanks for all your help!

    Jon
           
           

  63. Jonon 05 Jul 2006 at 8:39 pm

    ***UPDATE***

    I have managed to get the height and opacity of the reflection to work.

    At the top of the Lightbox script there are 2 variables ,reflectHeight and reflectOpacity, change these 2 variables from 0-1 and the rest will take car of itself.

    They are at the same locations as the previous post so Khlo, if you’d like to download them and then host them for others to use feel free!

    Thanks again 

  64. Khloon 05 Jul 2006 at 10:26 pm

    Okay! I’ve taken the lightbox download, modified it and added a little bit of documentation.

    You can get it at http://cow.neondragon.net/stuff/reflection/lightbox.zip. By the way, I didn’t have a URL or web page for you so at the moment it’s just credited to "Jon". If you want this changed or amended let me know!

  65. Jonon 06 Jul 2006 at 9:10 am

    Hi!

    Had a look and looks good!

    Hope it gets used lots!

    Cheers

    Jon 

  66. Seanon 06 Jul 2006 at 4:14 pm

    HI, i have a blog through blogger Techinacan.com and i was wondering how i could get this code to work on all the images in my posts. Could someone view the source of my site or something and tell me how to do this?

    Please Help!

    Contact me at webmasters@techinacan.com

  67. Seanon 06 Jul 2006 at 4:17 pm

    Sorry about the e-mail it’s not suppose to be linked…webmasters@techinacan.com“>

  68. Marjolein Katsmaon 06 Jul 2006 at 4:25 pm

    It doesn’t work on the latest Mozilla (Mozilla 1.7.12) - not ewxactly an "older browser" especially not when compared to IE 5.5. JavaScrit *not* disabled.

  69. Khloon 06 Jul 2006 at 8:27 pm

    You need Mozilla 1.8 for canvas tag support; the Mozilla Suite was discontinued at 1.7. It has been renamed to Seamonkey.

    Seamonkey is the updated version of the suite and I believe has Mozilla 1.8 so should support reflection.

    Sean: I’m not sure how to implement it into Blogger exactly but the instructions in readme.html should apply to Blogspot blogs too.

     

  70. Marjolein Katsmaon 11 Jul 2006 at 3:05 pm

    >> You need Mozilla 1.8 for canvas tag support.

    I was referring to the browser, not the engine. I have the latest Mozilla browser, which 1.7.12. (And no, it has not been "renamed" to Seamonkey - that’s a new project, actually.)

    Are you saying this Reflection.js requires support for a non-standard "canvas" element? "canvas" is not an element in HTML or XHTML. If it requires support for a non-standard element I’m not interested. 

    I would be interested to see a  standards-compliant implementation though.

  71. Khloon 11 Jul 2006 at 5:50 pm

    The Mozilla Engine is now up to 1.8 and Suite has been discontinued.

    Canvas is a new element which is standardized by HTML 5; Mozilla 1.7 is an old browser which does not implement it. Firefox/Seamonkey are considered the successors to Suite.

  72. Jamieon 11 Jul 2006 at 9:18 pm

    For the IE 6 A HREF tags not working…

    I added an onClick="document.location=’http://yourdomain/path’;" to the img tag and it seemed to work… but didn’t verify that this broke the link (left the A tag on too) in other browsers.

    Two issues I noticed though…

    1). no cursor change when rolling over what is now a link

    2). document.location call doesn’t seem to send the referrer environment variable - and I would like it to!!!!

  73. Manojon 12 Jul 2006 at 9:05 am

    Hi Khlo, thanx for sharing this script. I liked it and going to use it. 

    I am not able to resolve one issue here, I am trying to use onmouseover event

    to change class attribute of img, like the way I am changing width attribute

    in following code …..

     <table>
    <tr>
    <td>
    <img src="./images/personal/babymanoj_2.jpg" width="100" alt="" class="" />
    </td>
    <td>
    <img src="./images/personal/babymanoj_2.jpg" width="100" alt="" class="reflect" />
    </td>
    <td>
    <img src="./images/personal/babymanoj_2.jpg" width="100" alt="" class=""
     onmouseover="this.width=’150′;"
     onmousedown="this.width=’100′;"
     onmouseout ="this.width=’100′;"
     onmouseup  ="this.width=’150′;">
    </td>
    <td>
    <img src="./images/personal/babymanoj_2.jpg" width="100" alt="" class="reflect"
     onmouseover="this.class=”;"
     onmousedown="this.class=’reflect’;"
     onmouseout ="this.class=’reflect’;"
     onmouseup  ="this.class=”;">
    </td>
    </tr>
    </table>

     you can see the affect on this url : http://www.ae.uiuc.edu/~mparmar/reflection.html

    please suggest me how can I get the reflect and no reflect depending on

    if cursor is over image or away. 

     –Manoj

  74. Khloon 12 Jul 2006 at 9:51 am

    Hey,

    The best way to do this would be to use a scripted reflection. Adding the "reflect" class won’t work as reflection.js only checks for all images with that class when the page is loaded.

    Instead, use Reflection.add and Reflection.remove(). Try something like:

    onmouseover="Reflection.add(this)" onmouseout="Reflection.remove(this)"

  75. Manojon 13 Jul 2006 at 4:55 am

    grt, its working for me. thank you again Khlo

  76. Subon 14 Jul 2006 at 11:55 am

    I created a prototype of this for fun, when i was learning how reflection.js works.
    It’s created using a modified reflection.js, and uses java for file listing.

    Can only be run under Firefox, it enumerates all the image files in the folder the main.html belongs to. Only works on local offline file, i guess.

    But it’s only prototype. And I didnt copied the original credits and stuff, please amend it. Thanx !

     Download it at:

     http://www.freewebs.com/raguel49/TEST.rar

  77. Khloon 14 Jul 2006 at 12:26 pm

    Beautiful :) Thanks for linking!

  78. Marjolein Katsmaon 14 Jul 2006 at 10:00 pm

    @khlo,

    There is no such thing as a *standard* HTML 5. After HTML 4.01 followed XHTML 1.0 and XHTML 1.1. XHTML 2.0 is under development now. None of those define a "canvas" element.

    There is, however, a group calling itself the Web Hypertext Application Technology Working Group which is working on what it calls the ‘Web Applications 1.0′ specification (loosely referered to as "HTML 5" or XHTML 5" (which is it then?) wich currently is in *draft* status. Even if WHATWG were a standards organization (which it is not), "HTML 5" is still far from a standard, let alone a web standard.

    Sure, everyone is welcome to play in their own non-web-standard playground. Just don’t call it standards-compliant, and don’t call "HTML 5" a standard when clearly it is not.

    Of course, the ISO, a real standards organization, never really got anywhere with their own ISO HTML either (a real standard), except in a few (misguided) isolated pockets; it looks good on paper but they forgot one major thing: the whole point of (web) standards is interoperability - a rather strange thing to forget for a standards organization. Currently, only the W3C is creating web standards.

    If and when the W3C actually adopts the "Web Applications" specification the WHATWG is drafting I’ll be interested. Until then, Reflection.js is simply not standards-compliant and as such completely devoid of any interest to anyone who cares about web standards and interoperability.

    Why not create a standards-compliant version?

    I also take iissue with your calling Mizilla 1.7  and "old browser". Mozilla 1.7 is not that - it is, in fact still the most standards-compliant browser around, and as such quite modern. It is not even remotely comparable with IE 5.5 which definitely _is_ old and supposedly _is_ supported. (Addition of support for non-standard elements certainly does not make Seamonkey better, though I’ll take a look what it - potentially - has added (or dropped) in terms of standards support; I’ll need it for testing anyway.)

    Instead of describing not-supported browsers as "old" why not simply state "browsers that do not support the canvas element"? That would describe the situation a lot more accurately and thus be far less misleading.

  79. Khloon 15 Jul 2006 at 11:34 am

    Yes, it is arguable that HTML 5 is as much a standard as XHTML 2 is. The W3C does not have a monopoly on web standards; standard formats such as Javascript, XML-RPC, Atom and PNG have been developed by organizations other than the W3C and people are using those standards.

    The WHATWG is simply another of these organizations and what it’s "standards" or specs have been or are being implemented by Safari, Opera, KHTML and Gecko. Mozilla has implemented some SCS storage from the WHATWG specs in Firefox 2.0, Opera has Web Forms 2.0, etc.

    The problem with XHTML 2 is it tries to redefine everything and breaks things such as backwards compatibility. I think it’d take at least another 10 years for XHTML 2 to become the dominant language for web pages on the web, if it ever gets finished. However, the WHATWG are doing great work - listening to users of HTML and progressively enhancing on and building on HTML 4 adding features that developers want.

    I don’t care whether the W3C has blessed the standard or whether the specification is being developed under the arm of the W3C, the fact is that almost all browsers except from IE are implementing HTML 5 which in my eyes makes it as much of a standard as HTML 4.

    Until then, Reflection.js is simply not standards-compliant and as such completely devoid of any interest to anyone who cares about web standards and interoperability.

    I disagree with this statement; Reflection.js is interoperable and works in all 4 of the major browsers. I care about web standards but I also have no problem with using Reflection.js. HTML5 is the best way for the web to move forward at the moment and we shouldn’t let standards, and arguments over who wrote it, hold us back.

    Now, there is a reflection script from script.aculo.us which implements it using only HTML 4 and CSS but this method is slower and clogs up the DOM with a few hundred <div> elements. <canvas> is obviously a much better tool for the job and when it’s in the toolbox I don’t see why it can’t be used. However, if you are looking for a pure-HTML 4 solution, I recommend the scriptaculous reflector. 

    Of course Mozilla 1.7 is a great and standard-compliant browser; I was simply referring to the fact that it has been obseleted by the Mozilla 1.8 (Gecko 1.8) engine. 

  80. Marjolein Katsmaon 16 Jul 2006 at 7:47 am

    Never mind what browsers implement - what browsers implement does not make anything a standard.

    Something is a standard only when it is published AS a standard - and a DRAFT is not that. That is not the case for XHTML 2.0, and not HTML 5 which both are drafts.

    Merely looking at what browsers implement and calling that "interoperability" throws us right back to the 1990s and the very messy beginning of the web with browser manufacturers dreaming up their own tags and implementing them.

    I don’t want to go back there.

  81. Khloon 16 Jul 2006 at 12:11 pm

    Well, let’s just agree to disagree.

    I don’t believe standards have to be created through any organization - if a lot of people implement and use it in the same way it becomes a standard through use e.g. XmlHttpRequest.

    Atom 0.3 is considered a standard even though it was marked as a draft and was implemented in more or less every single feed reader out there and millions installations of blogging software such as Wordpress.

    WHATWG does not mean a return to the days of the 1990s - it means we don’t have to stay in the 2000s where HTML and web pages haven’t advanced because the W3C haven’t made any progress in years and XHTML 2.0 will probably never become finished. 

  82. Marjolein Katsmaon 18 Jul 2006 at 11:21 am

    OK, we’ll agree to disagree :)

    But there’s a difference between standardization and innovation (though that doesn’t exclude that a standard can be innovative). WHATWG clearly is in the field of innovation while the W3C is in the field of standardization.

    But if you say the W3C hasn’t made any progress in years you can’t have been paying much attention lately. They also regularly embrace innovations in their standards.

    And have you seen this? http://www.w3.org/WAI/PF/roadmap/DHTMLRoadmap040506.html

    (BTW, ATOM 1.0 _is_ a standard, while ATOM 0.3 never was anything but a draft; implementation does not change that.)

    Let it be clear that I have nothing at all against innovation. I just object to calling modern browsers "old" and old browsers "new", and I object to calling drafts standards. Enough for now. :)

    (And I absolutely HATE this comment editor which interferes with normal keyboard action. So if I stop my comments I won’t have to deal with that irritation anymore either. ;-))

  83. Orx57on 19 Jul 2006 at 11:14 am

    Hello,

    I discovered "reflection" recently. I use the package "lightbox2.02+reflection1.5"… where I replaced "reflection1.5" by "reflection1.6". On the following page, i use the code :

    <img src="http://photos.orx57.net/pictures/Aibo/Veda/.thumbs/thumb_IMG_1209.JPG" alt="" style="float:left; margin: 0 1em 1em 0;" class="reflect rheight10 ropacity20" />

    -> http://www.orx57.net/veda.php

    But there is a gap between image and reflection… after analysis, I do not understand this problem ! It works fine on reflect-o-matic tool.

    Does that come from another elements of my code?  

    Thank you for your assistance!

  84. Orx57on 19 Jul 2006 at 11:19 am

    Small precision: the same work fine here -> http://www.orx57.net/webcam.php

    This image is just larger…

    <img src="images/webcam.png" alt="Webcam@orx57" style="display:block; margin:0 auto;" longdesc="Webcam@orx57" class="reflect rheight10 ropacity20" />

    Bye!

  85. Khloon 19 Jul 2006 at 11:53 am

    Hi,

    I just took a look at http://www.orx57.net/veda.php and clicked on the Lightbox. It seemed to work fine and there was no gap between the image and the reflection.

  86. Orx57on 19 Jul 2006 at 1:00 pm

    Not on the Lightbox, but on the page, between the thumbnail and reflection… :)

  87. Clearon 19 Jul 2006 at 2:14 pm

    I’m not an expert on this but I think it’s likely because you’ve added padding to the image? There seems to be a 3px padding around teh whole image, which I assume will affect the reflection aswell.

  88. Orx57on 19 Jul 2006 at 3:22 pm

    I had thought of it… But without padding, it is the same! The reflection is correct with rheight > 20… and on bigger image with same CSS style…

  89. Orx57on 19 Jul 2006 at 3:27 pm

    It’s look fine on IE6… but not with Firefox 1.5.0.4… Actually, i’m on Windows XP.

  90. Orx57on 24 Jul 2006 at 2:10 pm

    No idea?

  91. Khloon 24 Jul 2006 at 5:39 pm

    Hi,

    Sorry for the slow response; thats a strange one. I know there was a bug like that but I thought it was fixed in 1.6; see if commenting the doctype changes it. If it removes it, there must still be an issue somewhere. 

  92. Orx57on 25 Jul 2006 at 2:07 pm

    Thanks !

    Yes, it’s work fine while commenting the doctype… 

    You can explain me this problem?
    Is it possible to make it function with the doctype?

  93. Khloon 25 Jul 2006 at 2:12 pm

    Hi,

    In XHTML Strict mode, Mozilla changes the way it renders images - images don’t appear on the baseline or something like that. Normally this can be fixed by changing the style on images - try adding img { vertical-align: bottom } to the CSS. Reflection.js is supposed to give reflected images this CSS so something must be working incorrectly.

     

  94. Orx57on 26 Jul 2006 at 8:56 am

    Ok. Thank you for information.

    It doesn’t work with the img style above.  I left the style in the css.

    I start to have concepts of Javascript and Ajax.  I will look at the code. Without claim… Just for my education :)

    Still thank you. 

    Bye. 

  95. Bryanon 31 Jul 2006 at 10:02 am

    I’d really like to see the reflection effect as a BBcode in phpBB. This would allow people to use it where they like in posts and sigs.  How about it, anyone?

  96. Anthony Nguyenon 04 Oct 2006 at 9:08 pm

    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.

  97. Tomekon 14 Oct 2006 at 4:38 pm

    Hi,

    In XHTML Strict mode, Mozilla changes the way it renders images - images don’t appear on the baseline or something like that. Normally this can be fixed by changing the style on images - try adding img { vertical-align: bottom } to the CSS. Reflection.js is supposed to give reflected images this CSS so something must be working incorrectly.

  98. Maxon 20 Oct 2006 at 12:12 pm

    Hi,

    Thanks for letting me know about the issues! I’d like to modify the script to include your changes; hope you don’t mind!

    Max

  99. Webkatalogon 22 Oct 2006 at 9:04 pm

    Wow, this code is absolutely amazing. I never knew this is possible with javascript. Thanks alot.

  100. Webkatalog Eintragon 26 Oct 2006 at 9:07 am

    The best way to do this would be to use a scripted reflection. Adding the "reflect" class won’t work as reflection.js only checks for all images with that class when the page is loaded.

     thanks for sharing this information

    Sandra

  101. FSDon 28 Oct 2006 at 5:37 pm

    Small precision: the same work fine here -> http://www.orx57.net/webcam.php

    This image is just larger…

  102. Aon 28 Oct 2006 at 5:41 pm

    I was fascinated by Apple UI’s reflection and started do it on my work , but using photoshop … now it;s on the fly

    thanks!

    Werner

  103. Plasmaon 30 Oct 2006 at 10:32 pm

    Looks really nice, i will integrate it directly in my site…

  104. Pensionon 31 Oct 2006 at 7:29 am

    Great function with such a little code, instead of photoshop work i will use the script now….

  105. Architekturaon 09 Nov 2006 at 12:55 am

    I like it - it’s fast and slim. Thanks.

  106. Roberton 10 Nov 2006 at 10:29 pm

    A very helpful script and great tips.

    Thanks guys!

  107. Pracaon 14 Nov 2006 at 12:54 pm

    I like it = it’s really fast - thanks forthis useful script.

  108. Rachunkowo347263on 25 Nov 2006 at 9:17 pm

    good script. thx.

  109. Simonon 28 Nov 2006 at 1:37 pm

    Reflection.js works in IE6 correct.

    A supernormal script!

    Thanks

  110. Finnlandon 01 Dec 2006 at 9:08 am

    Do you use the latest version of Opera?

  111. Metallbauon 01 Dec 2006 at 10:05 am

    any problems with safari?

  112. Khloon 01 Dec 2006 at 10:11 am

    Come on guys, this is not a place to post your SEO links.

  113. Vitaliy Malykinon 02 Dec 2006 at 11:42 am

    Seems to be really helpful, this script. I checked it with Firefox, Opera and IE6, but i couldnt install IE7, you know why..:) Has anybody have already checked with IE7?

  114. Khloon 04 Dec 2006 at 4:26 pm

    Since this version is now old and many of the solutions to issues can probably be found on the Reflection.js 1.6 page, I’m gonna close the comments. Feel free to post your comments and queries there.

Trackback URI | Comments RSS

Leave a Reply