MooTools Link Fading
We all know that we can set a different link color (among other properties) on the hover event, but why not show a little bit more dynamism by making the original color fade to the next? Using MooTools 1.2, you can achieve that effect.
The MooTools JavaScript
window.addEvent('domready',function() {
$each($$('.fade'), function(el) {
var original = el.getStyle('color');
var morph = new Fx.Morph(el,{ 'duration':'300', link:'cancel' });
el.addEvents({
'mouseenter' : function() { morph.start({ 'color':'#ff8c00' }) },
'mouseleave' : function() { morph.start({ 'color': original }) }
});
});
});
For every link with the fade class, a transition occurs on the mouseenter and mouseleave events. You'll place the "to" color in the spot designated in comments in the code above.
What are your thoughts on this? Too much? Just right? Let me know!
It's no secret that Facebook has become a major traffic driver for all types of websites. Nowadays even large corporations steer consumers toward their Facebook pages instead of the corporate websites directly. And of course there are Facebook "Like" and "Recommend" widgets on every website. One...
My trip to Mozilla Summit 2013 was incredible. I've spent so much time focusing on my project that I had lost sight of all of the great work Mozillians were putting out. MozSummit provided the perfect reminder of how brilliant my colleagues are and how much...
CSS animations are a lot of fun; the beauty of them is that through many simple properties, you can create anything from an elegant fade in to a WTF-Pixar-would-be-proud effect. One CSS effect somewhere in between is the CSS flip effect, whereby there's...
If you haven't heard of Woot.com, you've been living under a rock. For those who have been under the proverbial rock, here's the plot:
Every day, Woot sells one product.
Once the item is sold out, no more items are available for purchase.
You don't know how many...
Kinda cool, and could work in the right application. It’s always worth remembering what the users expects from a link though.
Unfortunately events don’t finish if a new one is fired right now, so the links can become locked to their active colour until the mouse enters again.
thats why i’m using mootools, thanks for the great idea, i’m looking to integrate it in my blog… ^^
I agree with Paul, there’s a problem with effects starting and ending.
Here is my solution, 100% mootools-sugar!
@thomasd: I’ll try that sometime today! Thanks for contributing!
the problem can be resolved simply like this:
@norpius: Yep, just got that a few minutes ago.
Hmm.. I thought Fx.Tween is enough for this..
Man, you’re F A N T A S T I C !
Why not use addClass()?
How I can implement this on wordpress sidebar links…
I’m got trouble adding class and id to the specified links.. tq..
I like this, useful and small. I think change my blog’s links. Thank you for sharing…
Hey one more cool script :)
Thanks man!
One quick question: How can I replace the “Color” with “Background Image” ?
I tired but it ain’t working :(
Any help would be appreciated!
yeah, I’m also looking at a way to do a background fade? any idea where to find this?
cheers
s
Hi,
Speed, Stefan, did you find the way to morph a photo by an other one ?
I accept with pleasure your solutons if you got some !
cheers
Hey,
What should I do to make it get the target color value from a specified css class instead of hard-coding it in the script as above?
I had a special class written to do it in 1.11, but it doesn’t work under 1.2.1. I’ve already received some feedback and I guess I can fix it, but that person suggested me using fx.morph, but looking at the given example I can’t really figure out how.
Thanks in advance,
Kind regards,
h-a-r-v
Hello,
I’m trying to write a link fading plugin for Joomla but i cant get it to work because Joomla uses Mootools 1.11
It seems mootools 1.11 doesnt know $each and Fx.morph
Do you have any advice how to get this to work with mootools 1.11?
Thank you!
Looks very sweet & simple and will deff. try this out. :)
But …
I would like only the underlines to fade, not the letters is this possible?
If so, how?
I think this should work:
Set in the CSS:
text-decoration: none;
for.fade
andtext-decoration: none; border-bottom: #000 1px solid;
for.fade:hover
Then replace in the script
color
withborder-bottom
and replace#ff8c00
with#ff8c00 1px solid
Adjust the color-codes and you’re done ;)
Isn´t it possible to use the link fading with the email protection script? Both together doesn´t work. :(
Hey, here’s code for MooTools 1.11 for menu in Joomla. Just assign ID in menu module configuration.
I got help from http://demos111.mootools.net/Fx.Styles
man you are awesome… really helpd me!!!
hi david
great code and thanks a lot for all you make !!
i use your script in a website with “opacity” and it work !
but I would like my div with
"opacity:0.5"
when the page open, and when you click on the div, it stay on"opacity:original"
(the link is on the same page with a function show/hide)Is that possible ?
thanks for your answers, and excuse me for my poor english (I’m french :-))
paps
Hi, thanks the script, simple and easy to use, but I definitely miss one small one function for the active class, i could figure it out it should look like a kind like that:
‘mouseenter’ : function() { morph.start({ ‘color’:’#2727f9′ }) },
‘mouseleave’ : function() { morph.start({ ‘color’: original }) },
‘click’ : function() { morph.start({ ‘color’:’#FF0000′ }) }
but on mouseleave the ‘click’ color should stay, anyone knows how?
best regards
the best way was only one clicked event is stored and overrides other actives with original color again
Your comment formatting screws up the “” thingys around the selectors!