Current User: Guest
Please consider registering

 
Search Forums:


 




Adding new default effects. [Advanced]

Post

Aaron - Admin

3:26 pm - January 11, 2009

posts 379

 
1

Post edited 3:37 pm - January 11, 2009 by Aaron


All the effects are run by a single JS file which just changes the styling of the elements. If you have any experience in JS and CSS, take a look at the /js/effects.css file. If you look for the various switch statements, those are the sections that control the effect.

Effects follow a simple pattern: the setup switch where the element is prepared — current stylings are saved, specific heights etc are set –, the actual effect which is just a changing of some CSS value in 10 steps either showing or hiding, and the cleanup where the effect is finished and defaults are restored etc.

For example:
(e is the element, i is the element id, _d[i] is an array of variables specific to the i)

This is the setup of the slideup effect:

  1. case 'SlideUp':
  2. _d[i]['height'] = $(i).offsetHeight;
  3. if (m === 'show') { /*We need an object to be displayed to retrieve height.*/
  4. e.position='absolute'; /*Pull the element out of its default location*/
  5. e.visibility='hidden'; /*Hide the element*/
  6. e.display='block';/*"Display" the hidden element*/
  7. _d[i]['height'] = $(i).offsetHeight;
  8. e.visibility=""; /*Show it*/
  9. e.position='relative'; /*Put it back where it was*/
  10. e.height = '0px'; /*shrink it for the effect.*/
  11. }
  12. e.overflow="hidden";
  13. break;
  14. Use the following to copy and paste the code.

This is the actual effect:

  1. case 'SlideUp':
  2. if ( m === 'hide' ) {
  3. e.height = Math.floor( _d[i]['height']*s*-0.1)+'px';
  4. _d[i].step += 1;
  5. } else {
  6. e.height = Math.floor( _d[i]['height']*(10-s)*0.1)+'px';
  7. _d[i].step -= 1;
  8. }
  9. break;
  10. Use the following to copy and paste the code.

This is the cleanup:

  1. case 'SlideUp':
  2. e.height = _d[i]['height']+'px';
  3. if(window.innerHeight){ /*IE has problems setting height to auto.*/
  4. e.height = 'auto';}
  5. e.overflow="visible";
  6. break;

If you have more questions let me know.

Florian Krebber - Guest

7:59 pm - June 24, 2009

 
2

And don't forget to include your new effect in the List in the AJAX Effects Tab. Do so in control/aWP-ajax.php on line 292-297. Just add another

  • -element.



  • Reply to Topic: Adding new default effects. [Advanced]

    NOTE: New Posts are subject to administrator approval before being displayed

    Name (Required):

    EMail (Required):

    Website):

    Topic Reply:

    HTML Editor
    Save New PostSmileysOptions

    Guest URL (required)

    Math Required!
    What is the sum of:
    4 + 1
       

     
    Confused Cool Cry Embarassed Frown Kiss Laugh Smile Surprised Wink Yell

     
     

    About the Ajaxed WordPress forum

    Most Users Ever Online:

    35


    Currently Online:

    9 Guests

    Forum Stats:

    Groups: 1

    Forums: 4

    Topics: 163

    Posts: 436

    Membership:

    There are 172 Members

    There have been 120 Guests

    There is 1 Admin

    There are 0 Moderators

    Top Posters:

    fromgrannie - 5

    jakemc - 5

    tombyrnes - 4

    BAM - 4

    Siam - 4

    flash - 4

    Administrators: Aaron (379 Posts)