OSDN Git Service

Add a degits property to the object
authordhrname <dhrname@users.sourceforge.jp>
Sun, 22 May 2016 12:31:34 +0000 (21:31 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sun, 22 May 2016 12:31:34 +0000 (21:31 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 13a8033..8eb24ba 100644 (file)
@@ -508,7 +508,7 @@ base("$from").of( {
     \r
 } )\r
  .mix( {\r
-   /*advanceã\83¡ã\82½ã\83\83ã\83\89ã\81§ä½¿ã\82\8fã\82\8cã\82\8bæ\9c\89å\8a¹æ\95°å­\97ã\81®æ¡\81æ\95° (å°\8fæ\95°ç\82¹ã\81®æ¡\81æ\95°ã\82\92決ã\82\81ã\82\8bã\81¨ã\81\8dã\81«ä½¿ã\81\86)*/\r
+   /*advanceã\83¡ã\82½ã\83\83ã\83\89ã\81®è¿\94ã\82\8aå\80¤ã\81§ä½¿ã\82\8fã\82\8cã\82\8bå°\8fæ\95°ç\82¹ä»¥ä¸\8bã\81®æ¡\81æ\95°*/\r
    degit: 0,\r
    \r
    /*additve属性やaccumulate属性が設定された、累積アニメーションか、加法アニメーションで使われる*/\r
@@ -1461,21 +1461,29 @@ base("$calcMode").up("$attribute").mix( {
     if (/^(?:display|class|edgeMode|(gradient|marker|pattern|maskContent|mask|patternContent|primitive)Units|in|in2|method|mode|operator|preserveAspectRatio|result|spacing|spreadMethod|stitchTiles|target|type|xlink:href|yChannelSelector|color-interpolation|(clip|fill)-rule|cursor|filter|font-(family|stretch|style|variant)|image-rendering|marker-(end|mid|start)|mask|overflow|pointer-events|shape-rendering|stroke-(linecap|linejoin)|text-(anchor|decoration|rendering)|visibility)$/.test(this.attrName) ) {\r
       this.mode = "discrete";\r
     }\r
-  }    \r
+  },\r
+  \r
+  /*小数点以下の桁数を指定するため、setValuesメソッドをオーバライドする*/\r
+  degits: 0,\r
+  setValues: function() {\r
+    var s = this.$attribute.setValues.apply(this, arguments),\r
+        degits = this.degits;\r
+    s && s.forEach(function(x) {\r
+      x.to.degit = degits;\r
+    } );\r
+    degits = void 0;\r
+    return s;\r
+  }\r
 \r
 /*initメソッドに追加処理\r
  * onメソッドについては、base.jsを参照のこと*/\r
 } ).on ("init", function(ele) {\r
   var isColor = /^(?:fill|stroke|stop-color|color)$/.test(this.attrName);\r
-  if (isColor) {\r
-    this.setValues = function() {\r
-      /*RGB形式では補間に、小数を使わない*/\r
-      var s = this.$attribute.setValues.apply(this, arguments);\r
-      s.forEach(function(x) {\r
-        x.to.degit = 0;\r
-      } );\r
-      return s;\r
-    };\r
+  if (!isColor) {\r
+    /*通常は、小数点以下の桁数を1桁としておく\r
+     *RGB形式では補間に、小数を使わないため、既定値の0のままにしておく\r
+     * (なお、この作業は、setKeyメソッドの前に済ませておく必要がある)*/\r
+    this.degits = 1;\r
   }\r
   var to, \r
       keyTime = 0,\r
@@ -1487,7 +1495,6 @@ base("$calcMode").up("$attribute").mix( {
     to = this.setKey(ele);\r
   }\r
   if (isColor) {\r
-    this.setValues = this.$attribute.setValues;\r
     /*#から始まる文字列を、rgb(.., .., ..,)形式へと変換するための関数*/\r
     var keywords = this._keywords;\r
     toRGB = function(rgbColor) {\r
index 4b10411..96ac30a 100644 (file)
@@ -1470,6 +1470,16 @@ describe("SMIL Animation Spec", function() {
       calc.to.from.string = "inline";\r
       expect(calc.call()(0.2)).toBe("inline");\r
       expect(calc.call()(0.3)).toBe("inline");\r
+      \r
+      calc.to = base("$from").up();\r
+      calc.to.from = base("$from").up();    \r
+      calc.mode = "linear";\r
+      calc.keyTime = 1;\r
+      calc.to.degit = 1;\r
+      calc.to.string = "1 1";\r
+      calc.to.from.string = "0.0 1";\r
+      expect(calc.call()(0.2)).toBe("0.2 1.0");\r
+      expect(calc.call()(0.3)).toBe("0.3 1.0");\r
     } );\r
     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
     it("should be this for the value (the invalid partion)", function() {\r