OSDN Git Service

Modify the getRotate method on the object
authordhrname <dhrname@users.sourceforge.jp>
Tue, 16 May 2017 13:46:56 +0000 (22:46 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Tue, 16 May 2017 13:46:56 +0000 (22:46 +0900)
org/w3c/dom/smil.js

index 0dd5e0c..a20b48b 100644 (file)
@@ -1000,6 +1000,7 @@ base("$calcMode").up("$attribute").mix( {
     return (s || def);\r
   },\r
   \r
+  /*アニメーション関連要素を収納*/\r
   _ele: document.documentElement,\r
   \r
   /*指定された要素にvalues属性が付いているかどうかのチェックできるメソッド*/\r
@@ -2052,7 +2053,15 @@ base("$calcMode").up("$attribute").mix( {
              y = point.y;\r
          /*一歩進んだ点*/\r
          point = path.getPointAtLength(advanceLength+1);\r
-         return ") rotate(" +(Math.atan2(point.y-y, point.x-x)/pi*180 + rotate)+ "";\r
+         var rad = Math.atan2(point.y-y, point.x-x);\r
+         if (rad === 0) {\r
+           /*アニメーションの終了間際では、radが0となるため、\r
+            * 代わりに、ベジェ曲線のハンドルの傾きから角度を求める*/\r
+           rad = Math.atan2(seg.y-seg.y2, seg.x-seg.x2);\r
+         }\r
+         return ") rotate(" +(rad/pi*180 + rotate)+ "";\r
+      } else {\r
+        return "";\r
       }\r
     },\r
     \r