- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
KennyP (11-17-2010)
John:
For as many times as I looked at the above code in your previous posting of it, I thought it referred
to the initial fade-in, which was already working perfectly. Finally I understood...
I tried it, and It's working flawlessly. Not only does the fade-out look better than that created by
the previous code, but it does not create any of the page sizing problems I mentioned earlier.
Out of curiosity, as I look at the code, am I guessing correctly that this same code could probably
function to create various types of animations by substituting their function names into the code?
Maybe scrolling the content down on page open, and scrolling it back up on page close, or an array
of different effects for different pages?
Thank you so much for your help,
Kenny
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
KennyP (11-17-2010)
Thanks for the info John. In the future maybe some other effect would work for the site design.
Although the code is now working so well, the Friends page still fades-in abruptly. I think it's due to the large content in that div, as all the other pages have little content, and they all fade in smoothly. There are about 150 comments entered, and growing. If you think of a way to deal with it, please let me know?
Many thanks,
Kenny
Last edited by KennyP; 11-17-2010 at 12:30 PM.
Hello again John:
As you know, I used your following script set at 0.60 : 0.60 in order to retain the translucent style
of the menu. However, on several other pages, in addition to the menu, I'd also like to fade other
images using a 1 : 1 setting. I tried to figure out how to add that variation to work on the same
page for over a day, but failed. When you get the opportunity, would you please show me how it
can be added?
This is just one of the pages showing two images of backward arrows I'd like to fade.
Code:<script type="text/javascript"> jQuery(function($){ var finOp = document.body.filters? 0.60 : 0.60; $('.jqImgFader').hover(function(){ $(this).find('img').css({opacity: 0, visibility: 'visible'}).animate({opacity: finOp}, 400); }, function(){ $(this).find('img').animate({opacity: 0}, 400); }); }); </script>
Thank you,
Kenny
Last edited by KennyP; 11-22-2010 at 09:30 AM.
The:
selects the td elements of theCode:$('.jqImgFader')class="jqImgFader"which each must have one background image and then another similar (in dimensions and look) actual image (using an img tag) that gets faded in on top. So for this to be portable to other rollovers, a similar HTML markup must be used. There's also style (the width and height are applied to the td elements but are those of the images):
associated with these rollovers. A different class name would probably be the best way to distinguish one type or set of rollovers from another. This class then would be used in the markup, the function as well as in the style.Code:<style type="text/css"> .jqImgFader { width: 164px; height: 38px; } .jqImgFader img { visibility: hidden; } </style>
Since you are using0.60 : 0.60, you don't really need to test for filters. But with1 : 1, you may need to. You will if the faded in image is .png and has partial opacity.
So let's say your additional class is jqImgFader2 and the images are 125 x 80 and you have setup a similar HTML markup for them (additions highlighted):
and:Code:<style type="text/css"> .jqImgFader { width: 164px; height: 38px; }.jqImgFader2 { width: 125px; height: 80px; }.jqImgFader img, .jqImgFader2 img{ visibility: hidden; } </style>
Both the styles and the script may be made external and be linked/tagged into the head of the page(s) using either of these classes.Code:<script type="text/javascript"> jQuery(function($){var finOp1 = 0.60, finOp2 = document.body.filters? 0.90 : 1;$('.jqImgFader, .jqImgFader2').hover(function(){var el = $(this), finOp = el.hasClass('jqImgFader')? finOp1 : finOp2;el.find('img').css({opacity: 0, visibility: 'visible'}).animate({opacity: finOp}, 400); }, function(){ $(this).find('img').animate({opacity: 0}, 400); }); }); </script>
Note: This is all untested.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
KennyP (11-22-2010)
Thank you for your reply, especially because of your explanation in addition to the code.
As you can see on this page, the additional image class is fading perfectly.
I made the effort to enter the td code as I did for the menu, but for some reason, the fading over image displays
with the effect of a button being pushed in.
The folowing is correct no?
Many thanks for the rescue and Regards,Code:<td class="jqImgFader2" background="/images/back-white.gif" width="232" height="20" style="background-repeat:no-repeat"><a href="$return_link"><img src="/images/back-red.gif" width="232" height="20" border="0"></a></td>
Kenny
Last edited by KennyP; 11-22-2010 at 02:01 PM.
Hi John:
Sorry to have to bring this up again... suddenly the onbeforeonload opacity fades only to about 50%, whereas previously it faded entirely. What could have happened? When you get the opportunity would you please take a look? Thanks.
Welcome page
Home page
jqOpacityFade.js:Code:(function($){ $('head').append('<style type="text/css">#d1 {visibility: hidden;}</style>'); $(function(){ $('#d1').css({opacity: 0, visibility: 'visible'}).animate({opacity: 1}, 1300, 'linear', function(){ if(typeof fleXenv === 'object' && typeof fleXenv.globalInit === 'function'){ fleXenv.globalInit(); } if(this.style.getAttribute){ this.style.removeAttribute('filter'); } }); }); window.onbeforeunload = function(){ $('#d1').animate({opacity: 0}); }; })(jQuery);
Last edited by KennyP; 01-24-2011 at 09:51 PM.
I tried setting the animate opacity setting to minus numbers, but the fade is lost. So I set it back to 0.
Code:window.onbeforeunload = function(){ $('#d1').animate({opacity:-5});
Last edited by KennyP; 01-28-2011 at 10:08 AM.
Well, if it was working before, perhaps you have a backup. Looking at it, it appears as though there just isn't enough time. The beforeunload is meant for a one shot deal - do something(s) real quickly, as quickly as possible before the page unloads. The animate method requires transformation over time. So if we speed it up, that might allow it to complete:
If that works, we may be able to slow it down again by delaying the loading of the next page. But that would be tricky, so let's do this test first.Code:window.onbeforeunload = function(){ $('#d1').animate({opacity: 0}, 'fast'); };
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
KennyP (01-28-2011)
Bookmarks