MooTools - 弹性过渡



使用有 in、out 和 in-out 事件的弹性曲线过渡。我们举个例子,在 div 元素中,添加一个鼠标按下事件,同时还有弹性曲线事件。请看以下代码。

示例

<!DOCTYPE html>
<html>

   <head>
      <style>
         #elastic_in {
            width: 100px;
            height: 20px;
            background-color: #F4D03F;
            border: 2px solid #808B96;
         }
         #elastic_out {
            width: 100px;
            height: 20px;
            background-color: #F4D03F;
            border: 2px solid #808B96;
         }
         #elastic_in-out {
            width: 100px;
            height: 20px;
            background-color: #F4D03F;
            border: 2px solid #808B96;
         }
      </style>
      
      <script type = "text/javascript" src = "MooTools-Core-1.6.0.js"></script>
      <script type = "text/javascript" src = "MooTools-More-1.6.0.js"></script>
      
      <script type = "text/javascript">
         window.addEvent('domready', function() {
            $('elastic_in').addEvent('mousedown', function(event) {
               this.set('tween', {duration: 'long', transition: 'elastic:in'});
               this.tween('width', [80, 400]);
            });
            
            $('elastic_out').addEvent('mousedown', function(event) {
               this.set('tween', {duration: 'long', transition: 'elastic:out'});
               this.tween('width', [80, 400]);
            });
            
            $('elastic_in-out').addEvent('mousedown', function(event) {
               this.set('tween', {duration: 'long', transition: 'elastic:in-out'});
               this.tween('width', [80, 400]);
            });
         });
      </script>
   </head>
   
   <body>
      <div id = "elastic_in"> Elastic : in</div><br/>
      <div id = "elastic_out"> Elastic : out</div><br/>
      <div id = "elastic_in-out"> Elastic : in-out</div><br/>
   </body>
   
</html>

您将收到以下输出 −

输出

mootools_fxoptions.htm
广告