MooTools - 線性轉換



透過 in、out 和 in-out 事件展示一個線性轉換。我們以一個示例來進行講解,其中,我們在一個 div 元素上新增一個滑鼠按下事件,以及線性事件。檢視以下程式碼。

示例

<!DOCTYPE html>
<html>

   <head>
      <style>
         #linear_in {
            width: 100px;
            height: 20px;
            background-color: #F4D03F;
            border: 2px solid #808B96;
         }
         #linear_out {
            width: 100px;
            height: 20px;
            background-color: #F4D03F;
            border: 2px solid #808B96;
         }
         #linear_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() {
            $('linear_in').addEvent('mousedown', function(event) {
               this.set('tween', {duration: 'long', transition: 'linear:in'});
               this.tween('width', [80, 400]);
            });
         
            $('linear_out').addEvent('mousedown', function(event) {
               this.set('tween', {duration: 'long', transition: 'linear:out'});
               this.tween('width', [80, 400]);
            });
         
            $('linear_in-out').addEvent('mousedown', function(event) {
               this.set('tween', {duration: 'long', transition: 'linear:in-out'});
               this.tween('width', [80, 400]);
            });
         });
      </script>
   </head>
   
   <body>
      <div id = "linear_in"> Linear : in</div><br/>
      <div id = "linear_out"> Linear : out</div><br/>
      <div id = "linear_in-out"> Linear : in-out</div><br/>
   </body>
   
</html>

你將收到以下輸出 −

輸出

mootools_fxoptions.htm
廣告
© . All rights reserved.