SoFunction
Updated on 2025-03-01

How to write a general JavaScript effect library! (2/2)


/**//****************************************************/ 
// Move, here is move to  that means moving to x,y Of course, you can also expand another move by  moving x pixels
=function(effect){   //Initialization
    if (!==undefined || !==undefined){         
        var pos=(); 
               =pos[0]; 
                  =pos[1]; 
         =;      
            ="absolute" 
        =(===undefined)?:; 
        =(===undefined)? :;                         
    } 

=function(effect,pos){     //Effect
    if (===undefined && ===undefined) return         
    = + () * pos +"px"; 
     =  + ( ) * pos +"px"; 

/**//****************************************************/ 

/**//****************************************************/ 
// zoom   by Go_Rush(A Shun) from /
=function(effect){     
          = || 1; 
// firefox Do not support css zoom Use the method of changing width and height instead
    if (!==undefined && ().indexOf('firefox') != -1){                     
        =  * ; 
        = * ;     
    } 

=function(effect,pos){ 
    if (===undefined) return; 
    =+()*pos 

/**//****************************************************/ 
/**//****************************************************/ 
// size  Same as above, it is size to, change to the specified size by Go_Rush(A Shun) from /
=function(effect){ 
    if (!==undefined || !==undefined){ 
           = || 'visible'; 
              =; 
              =;  
         ="hidden"     
        =(===undefined)? :; 
        =(===undefined)?:;             
    } 

=function(effect,pos){     
    if (===undefined && ===undefined) return; 
     = + ( ) * pos +"px"; 
    =+ () * pos +"px"; 

/**//****************************************************/ 
/**//****************************************************/ 
// Background color by Go_Rush(A Shun) from /
=function(effect){ 
    if (!==undefined && /^\#?[a-f0-9]{6}$/()){ 
        var color = || "#ffffff"; 
// Under FireFox, even if the css style is set to #ffffff format, the program gets the rgb(255,255,255) format, here it is converted to #ffffff format
        if (/rgb/(color)){               // "rgb(255, 0, 255)" 
            //var arr=(/[rgb\(\s\)]/gi,"").split(",") 
            var arr=eval(("rgb","new Array"))        
            color="#"+Number(arr[0]).toColorPart()+Number(arr[1]).toColorPart()+Number(arr[2]).toColorPart() 
        } 
        =color 
    } 

=function(effect,pos){     
    if (===undefined) return; 
    var c1=,c2= 
    var arr1=[parseInt((1,3),16),parseInt((3,5),16),parseInt((5),16)] 
    var arr2=[parseInt((1,3),16),parseInt((3,5),16),parseInt((5),16)] 
    var r=(arr1[0]+(arr2[0]-arr1[0])*pos) 
    var g=(arr1[1]+(arr2[1]-arr1[1])*pos) 
    var b=(arr1[2]+(arr2[2]-arr1[2])*pos) 
    ="#"+()+()+() 

/**//****************************************************/ 
/**//****************************************************/ 
// Transparency, this one has been posted in the previous post   by Go_Rush(A Shun) from /
=function(effect){ 
    if (===undefined) return; 
    =Opacity();     

=function(effect,pos){ 
    if (===undefined) return; 
    Opacity(,+()*pos);     

/**//****************************************************/