OSDN Git Service

Add a listenr method
authordhrname <dhrname@users.sourceforge.jp>
Wed, 4 Feb 2015 14:26:51 +0000 (23:26 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Wed, 4 Feb 2015 14:26:51 +0000 (23:26 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 5bc1957..2222dcd 100644 (file)
@@ -200,6 +200,15 @@ base("$frame").mix ( {
     \r
     /*イベントが適用される要素*/\r
     eventTarget: document.documentElement,\r
+    \r
+    /*イベントのリスナーとして、parseメソッドで使う*/\r
+    listener: function(evt) {\r
+      /*以下の式については、開始時刻を求める式なので、\r
+       * W3C仕様 SMILアニメーション 「3.2.1. アニメーション関数のタイミング」を参照*/\r
+      var rD = evt.timeStamp - Date.now(),\r
+          o = Math.abs(this.begin),\r
+          mb = o - ( d * Math.floor(o / d) ) - rD;\r
+    },\r
 \r
     /*trim メソッド\r
      * 文字列中の空白を除去*/\r
@@ -261,7 +270,8 @@ base("$frame").mix ( {
       this.begin = 0;\r
       var str = this.trim(),\r
           plusminus = str.search(/[\+\-]/),\r
-          event = null;\r
+          event = null,\r
+          ele;\r
       if (plusminus > 0) {\r
         /*Event-Value +/- Clock-Value の場合*/\r
         this.begin = this.offset( str.slice(plusminus) );\r
@@ -276,6 +286,9 @@ base("$frame").mix ( {
         this.isResolved = true;\r
       }\r
       if (event) {\r
+        ele = event.id ? this.eventTarget.ownerDocument.getElementById(event.id)\r
+                        : this.eventTarget;\r
+        ele && ele.addEventListener(event.event, this.listener.bind(this));\r
       }\r
       return this;\r
     }\r
index b0cc823..2db3a0d 100644 (file)
@@ -2120,6 +2120,7 @@ describe("SMIL Animation Spec", function() {
       expect(begin.string).toBe("");\r
       expect(begin.isResolved).toBeFalsy();\r
       expect(begin.eventTarget).toBe(document.documentElement);\r
+      expect(typeof begin.listener).toEqual("function");\r
     } );\r
     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
     it("should be this for the value (the valid partion)", function() {\r