Link Fader

Don Von Alpha Dom
by Don Von Alpha Dom · 8 posts
14 years ago in General
Posted 14 years ago · Author
I love this code.

Code
<Script>
/*******************************************************************
* File    : JSFX_LinkFader.js  © JavaScript-FX.com
* Created : 2002/09/05
* Author  : Roy Whittle  (Roy@Whittle.com) www.Roy.Whittle.com
* Purpose : To create a more dynamic a:hover using fading
* History
* Date         Version        Description
* 2002-09-05   1.0      First version
***********************************************************************/
/*** Create some global variables ***/
if(!window.JSFX)JSFX=new Object();

var LinkFadeInStep=20;
var LinkFadeOutStep=5;
var LinkEndColor="FF0000"

var LinkStartColor="FFFFFF";
var LinkFadeRunning=false;

document.onmouseover = theOnOver;
document.onmouseout  = theOnOut;
if(document.captureEvents)
    document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);

/***********************************************
*
* Function    : getColor
*
* Parameters  :   start - the start color (in the form "RRGGBB" e.g. "FF00AC")
*         end - the end color (in the form "RRGGBB" e.g. "FF00AC")
*         percent - the percent (0-100) of the fade between start & end
*
* returns     : color in the form "#RRGGBB" e.g. "#FA13CE"
*
* Description : This is a utility function. Given a start and end color and
*          a percentage fade it returns a color in between the 2 colors
*
* Author     : www.JavaScript-FX.com
*
*************************************************/
function hex2dec(hex){return(parseInt(hex,16));}
function dec2hex(dec){return (dec < 16 ? "0" : "") + dec.toString(16);}
function getColor(start, end, percent)
{

   var r1=hex2dec(start.slice(0,2));
   var g1=hex2dec(start.slice(2,4));
   var b1=hex2dec(start.slice(4,6));

   var r2=hex2dec(end.slice(0,2));
   var g2=hex2dec(end.slice(2,4));
   var b2=hex2dec(end.slice(4,6));

   var pc=percent/100;

   var r=Math.floor(r1+(pc*(r2-r1)) + .5);
   var g=Math.floor(g1+(pc*(g2-g1)) + .5);
   var b=Math.floor(b1+(pc*(b2-b1)) + .5);

   return("#" + dec2hex(r) + dec2hex(g) + dec2hex(b));
}
/************************************************/
JSFX.getCurrentElementColor = function(el)
{
   var result = LinkStartColor;

   if (el.currentStyle)
      result = (el.currentStyle.color);
   else if (document.defaultView)
      result = (document.defaultView.getComputedStyle(el,'').getPropertyValue('color'));
   else if(el.style.color) //Opera
      result = el.style.color;

   if(result.charAt(0) == "#")      //color is of type #rrggbb
      result = result.slice(1, 8);
   else if(result.charAt(0) == "r") //color is of type rgb(r, g, b)
   {
      var v1 = result.slice(result.indexOf("(")+1, result.indexOf(")") );
      var v2 = v1.split(",");
      result = (dec2hex(parseInt(v2[0])) + dec2hex(parseInt(v2[1])) + dec2hex(parseInt(v2[2])));
   }

   return result;
}
JSFX.findTagIE = function(el)
{
      while (el && el.tagName != 'A')
            el = el.parentElement;
   return(el);
}
JSFX.findTagNS= function(el)
{
      while (el && el.nodeName != 'A')
            el = el.parentNode;
   return(el);
}
function theOnOver(e)
{
   var lnk;
   if(window.event)
      lnk=JSFX.findTagIE(event.srcElement);
   else
      lnk=JSFX.findTagNS(e.target);

   if(lnk)
      JSFX.linkFadeUp(lnk);
}
JSFX.linkFadeUp = function(lnk)
{
   if(lnk.state == null)
   {
      lnk.state = "OFF";
      lnk.index = 0;
      lnk.startColor = JSFX.getCurrentElementColor(lnk);
      lnk.endColor = LinkEndColor;
   }

   if(lnk.state == "OFF")
   {
      lnk.state = "FADE_UP";
      JSFX.startLinkFader();
   }
   else if( lnk.state == "FADE_UP_DOWN"
      || lnk.state == "FADE_DOWN")
   {
      lnk.state = "FADE_UP";
   }
}
function theOnOut(e)
{
   var lnk;
   if(window.event)
      lnk=JSFX.findTagIE(event.srcElement);
   else
      lnk=JSFX.findTagNS(e.target);

   if(lnk)
      JSFX.linkFadeDown(lnk);
}
JSFX.linkFadeDown = function(lnk)
{
   if(lnk.state=="ON")
   {
      lnk.state="FADE_DOWN";
      JSFX.startLinkFader();
   }
   else if(lnk.state == "FADE_UP")
   {
      lnk.state="FADE_UP_DOWN";
   }
}
JSFX.startLinkFader = function()
{
   if(!LinkFadeRunning)
      JSFX.LinkFadeAnimation();
}
/*******************************************************************
*
* Function    : LinkFadeAnimation
*
* Description : This function is based on the Animate function
*              of animate.js (animated rollovers).
*              Each fade object has a state. This function
*              modifies each object and changes its state.
*****************************************************************/
JSFX.LinkFadeAnimation = function()
{
   LinkFadeRunning = false;
   for(i=0 ; i<document> 100)
               lnk.index = 100;
            lnk.style.color=getColor(lnk.startColor, lnk.endColor, lnk.index);

            if(lnk.index == 100)
               lnk.state="ON";
            else
               LinkFadeRunning = true;
         }
         else if(lnk.state == "FADE_UP_DOWN")
         {
            lnk.index+=LinkFadeOutStep;
            if(lnk.index>100)
               lnk.index = 100;
            lnk.style.color=getColor(lnk.startColor, lnk.endColor, lnk.index);

            if(lnk.index == 100)
               lnk.state="FADE_DOWN";
            LinkFadeRunning = true;
         }
         else if(lnk.state == "FADE_DOWN")
         {
            lnk.index-=LinkFadeOutStep;
            if(lnk.index<0)
               lnk.index = 0;
            lnk.style.color=getColor(lnk.startColor, lnk.endColor, lnk.index);
   
            if(lnk.index == 0)
               lnk.state="OFF";
            else
               LinkFadeRunning = true;
         }
      }
   }
   /*** Check to see if we need to animate any more frames. ***/
   if(LinkFadeRunning)
      setTimeout("JSFX.LinkFadeAnimation()", 40);
}
</Script>
Posted 14 years ago
if this is code that make panels shady and when u move mouse over they get brighter then i love code and u
Posted 14 years ago
My guess is that it fades the panels, when we roll the mouse over them, the panels highlight.
Posted 14 years ago
we need to create a code that only applies to imvu mafia members... like only we can c the pages :twisted:
Posted 14 years ago
i dont believe we could make something that will only allow mafia members ... hmm cos visitor when he comes he only brings some date .. like his ID ... name ... nothing more .. if he would bring group name he is in .. we could select them that way and only one who belong to some group we let see some stuff ..

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT
Select a forum Protection     Help & Support     Introductions     Mafia News     IMVU News General Discussion     IMVU Lounge        IMVU Series / Roleplaying        Social Games     Mafia Market     Mafia Tools        Premium IMVU Tools        Off Topic Tools     Off Topic     Contests Creator Corner     Graphics Design        Photoshop        GIMP     Basic Creator Help     Catalog And Product Showcase     3D Meshing        3Ds Max        Sketchup        Blender Gangsters with Connections     White Hat Activities        Google Hacking        Trackers Programming Corner     Coding        Python        .Net (C#, VB, etc)        Flash        JAVA        Autoit        Batch        HTML & CSS        Javascript        PHP        Other        IMVU Homepage Codes           General           About me Panel           Messages Panel           Special Someone Panel           Visitors Panel           New Products Panel           Rankings Panel           Wishlist Panel           My Badges Panel           Outfits Panel           Url Panel           Groups Panel           Slideshow Panel           My Room Panel           Sandbox panel           Layouts     Help & Requests Free Credits     Approved Methods     Submit Methods Free Money     Approved Methods     Submit Methods Adult Corner     Get Mafia AP Here     AP Lounge        AP Social Games        Casual Dating Tips     IMVU Slave Market & Escorts