Animate position and size : Animate « Rico « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Dojo toolkit
7. Event
8. Event onMethod
9. Ext JS
10. Form Control
11. GUI Components
12. HTML
13. Javascript Collections
14. Javascript Objects
15. Javascript Properties
16. jQuery
17. Language Basics
18. Mochkit
19. Mootools
20. Node Operation
21. Object Oriented
22. Page Components
23. Rico
24. Scriptaculous
25. Security
26. SmartClient
27. Style Layout
28. Table
29. Utilities
30. Window Browser
31. YUI Library
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
JavaScript DHTML » Rico » Animate 
Animate position and size
 
<!--
Apache License, Version 2.0

Revised from Rico 2.0  demo code.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<title>Rico</title>

<script src="rico21/src/rico.js" type="text/javascript"></script>
<script type='text/javascript'>
Rico.loadModule('Corner','Effect');
var EffectDemo,div1,div2;
Rico.onLoadfunction() {
  EffectDemo = Class.create();
  EffectDemo.prototype = {
    initialize: function(element) {
      this.animator = new Rico.Effect.Animator();
      this.element = $(element);
      this.startLeft = this.element.offsetLeft;
      this.startSize = this.element.offsetWidth;
    },
    sizeEffectStarted: false,
    positionEffectStarted: false,
    fadeEffectStarted: false,
    play: function(effect) {
      this.animator.play(effect, {steps:20, duration:700});
    },
    togglePosition: function(){
      this.play(new Rico.Effect.Position(this.element, this.nextPosition()null));
    },
    toggleSize: function(){
      this.play(new Rico.Effect.SizeAndPosition(this.element, null, null, this.nextSize()null));
    },
    toggleSizeAndPosition: function(){
      this.play(new Rico.Effect.SizeAndPosition(this.element, this.nextPosition(), null, this.nextSize()null ));
    },
    togglePositionAndFade: function(){
      this.play(new Rico.Effect.SizeAndPositionFade(this.element, this.nextPosition(), null, null, null, this.nextFadeState() ));
    },
    toggleFade: function(){
      this.play(new Rico.Effect.FadeTo(this.element, this.nextFadeState()));
    },
    nextPosition: function(){
      this.positionEffectStarted = !this.positionEffectStarted;
      return !this.positionEffectStarted ? this.startLeft : 520;
    },
    nextSize: function(){
      this.sizeEffectStarted = !this.sizeEffectStarted;
      return !this.sizeEffectStarted ? this.startSize : 350;
    },
    nextFadeState: function(){
      this.fadeEffectStarted = !this.fadeEffectStarted;
      return !this.fadeEffectStarted ? 0;
    }
  };
  Rico.Corner.round('effect_object_r', useMoz: false });  // don't use native corner rounding in Gecko because animation leaves artifacts
  div1=new EffectDemo('effect_object');
  div2=new EffectDemo('effect_object_r');
});
</script>

<style type="text/css">
body, p {
  font-family : Trebuchet MS, Arial, Helvetica, sans-serif;
  font-size   : 11px;
}
h1 {
  font-family : Trebuchet MS, Arial, Helvetica, sans-serif;
  font-size: 16pt;
}

div.sizeMe {
   width            : 120px;
   background-color : #c6c3de;
   padding-top      : 10px;
   padding-bottom   : 10px;
   font-family      : Arial;
   font-size        : 11px;
   text-align       : center;
   position         : absolute;
}
</style>


</head>


<body>

<h1 style='float:left;'>Rico Animation &amp; Effects</h1>
<p style='clear:both;'>
<table border='0'>
<tr>
<td>
<td><button onclick="div1.toggleSize(); div2.toggleSize();">Animate Size</button>
<td><button onclick="div1.toggleFade(); div2.toggleFade();">Fade Out/Fade In</button>

<tr>
<td><button onclick="div1.togglePosition(); div2.togglePosition();">Animate Position</button>
<td><button onclick="div1.toggleSizeAndPosition(); div2.toggleSizeAndPosition();">Animate Position & Size</button>
<td><button onclick="div1.togglePositionAndFade(); div2.togglePositionAndFade();">Animate Position & Fade</button>
</table>


<p>&nbsp;

<div id="effect_object" class="sizeMe" style="border: 6px solid black;">
   <div style="height:50px; background-color:red;">Inner div content
   </div>
</div>

<p style="height:100px;">&nbsp;

<div id="effect_object_r" class="sizeMe">
   <div style="height:50px; background-color:red;">Inner div content
   </div>
</div>

</body>
</html>

   
  
Related examples in the same category
1. Animate size
2. Animate position
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.