OSDN Git Service

Lighten the setKey method
authordhrname <dhrname@users.sourceforge.jp>
Wed, 8 Feb 2017 12:14:42 +0000 (21:14 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Wed, 8 Feb 2017 12:14:42 +0000 (21:14 +0900)
org/w3c/dom/smil.js

index 1da1374..76340f1 100644 (file)
@@ -1315,6 +1315,7 @@ base("$calcMode").up("$attribute").mix( {
           this.getAttr("from", null),\r
           this.getAttr("to", null),\r
           this.getAttr("by", null) ),\r
+         toLength = to ? to.length : 0,\r
          keyTimes = this.getAttr("keyTimes", null),\r
          keySplines = this.getAttr("keySplines", null),\r
          keys,\r
@@ -1330,7 +1331,7 @@ base("$calcMode").up("$attribute").mix( {
         return null;\r
       }\r
       /*toオブジェクトはtoとfromで一組となっているのでlengthが加算される*/\r
-      if (this.isKeyError(keys.length, to.length)) {\r
+      if (this.isKeyError(keys.length, toLength)) {\r
         /*keyTimes属性とvalues属性のリストの個数が合致しない場合、アニメーションの効果がない\r
          * 仕様を参照 SMIL Animation 3.2.3. Animation function calculation modes\r
          * http://www.w3.org/TR/smil-animation/#AnimFuncCalcMode*/\r
@@ -1345,7 +1346,7 @@ base("$calcMode").up("$attribute").mix( {
          */\r
         return null;\r
       }\r
-      for (var i=0;i<to.length;++i) {\r
+      for (var i=0;i<toLength;++i) {\r
         to[i].keyTime = keys[i+1] - keys[i];\r
         if (splines) {\r
           toiKeySplines = this.$from.numList.call( {\r
@@ -1356,8 +1357,8 @@ base("$calcMode").up("$attribute").mix( {
         }\r
       }\r
     } else if (!isDiscrete && to) {\r
-      var per = 1 / to.length;\r
-      for (var i=0;i<to.length;++i) {\r
+      var per = 1 / toLength;\r
+      for (var i=0;i<toLength;++i) {\r
         to[i].keyTime = per;\r
         if (splines) {\r
           toiKeySplines = this.$from.numList.call( {\r
@@ -1376,20 +1377,20 @@ base("$calcMode").up("$attribute").mix( {
         if (keys.length && (keys[0] !== 0)) {\r
           return null;\r
         }\r
-        if (this.isKeyError(keys.length, to.length)) {\r
+        if (this.isKeyError(keys.length, toLength)) {\r
           return null;\r
         }\r
-        for (var i=0;i<to.length;++i) {\r
+        for (var i=0;i<toLength;++i) {\r
           to[i].keyTime = keys[i+1] - keys[i];\r
         }\r
       } else {\r
-        var per = 1 / (to.length+1);\r
-        for (var i=0;i<to.length;++i) {\r
+        var per = 1 / (toLength+1);\r
+        for (var i=0;i<toLength;++i) {\r
           to[i].keyTime = per;\r
         }\r
       }\r
       /*toオブジェクトが足らないので、一つ追加しておく*/\r
-      to.push( to[to.length-1].up().mix( function(){\r
+      to.push( to[toLength-1].up().mix( function(){\r
           if (!keys) {\r
             return;\r
           }\r