From 7c72cd0491c048e51396f9bcb3999595a8b23c18 Mon Sep 17 00:00:00 2001 From: dhrname Date: Thu, 3 Nov 2016 22:53:24 +0900 Subject: [PATCH] Modify the setSmilEvent for a repeat event --- org/w3c/dom/smil.js | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/org/w3c/dom/smil.js b/org/w3c/dom/smil.js index 98a3e81..67e21aa 100644 --- a/org/w3c/dom/smil.js +++ b/org/w3c/dom/smil.js @@ -1045,26 +1045,65 @@ base("$calcMode").up("$attribute").mix( { * setSmilEventメソッドを見よ*/ _repeatList: [], + /*リピート回数を示すプロパティ + * setSmilEventメソッドを見よ*/ + _repeatCount: 0, + /*SMILイベント関連を発火させるためのメソッド * もっぱら、push メソッドで使われる*/ setSmilEvent: function($list) { - var detail = 0; $list.addEvent("begin", function($list) { - var target = this._ele; + var target = this._ele, + detail = 0; /*IE11のために、MouseEventsでSMILEventsの代用をする*/ var evt = target.ownerDocument.createEvent("MouseEvents"); evt.initMouseEvent("beginEvent" ,true, true, window, detail, 0, 0, 0, 0, false, false, false, false, 0, target); target.dispatchEvent(evt); /*repeatイベントのために、_repeatListプロパティを初期化する*/ var list = this._repeatList = [], + begin = $list.begin, + end = $list.end, simpleDuration = this.timeline.simpleDuration; - }.bind(this) ); + if (simpleDuration && (simpleDuration !== end - begin)) { + /*活動継続時間と単純持続時間が異なるとき、repeatイベントを設定*/ + for (var m= begin + simpleDuration, n=1;m < end; m+=simpleDuration) { + list.push( { + frame: m, + /*リピートの回数 (n >= 1)*/ + count: n + } ); + ++n; + } + $list.addEvent("play", function($list) { + var target = this._ele, + detail = 0, + frame = $list.currentFrame, + list = this._repeatList; + if (!list.length) { + return; + } + for (var i=0;i= i+1) + || (list[i].frame >= frame) ) { + this._repeatCount = detail; + break; + } + detail = list[i].count; + var evt = target.ownerDocument.createEvent("MouseEvents"); + evt.initMouseEvent("repeatEvent" ,true, true, window, detail, 0, 0, 0, 0, false, false, false, false, 0, target); + target.dispatchEvent(evt); + } + }.bind(this) ); + } + }.bind(this) ); + $list.addEvent("end", function() { - var target = this._ele; + var target = this._ele, + detail = 0; var evt = target.ownerDocument.createEvent("MouseEvents"); evt.initMouseEvent("endEvent" ,true, true, window, detail, 0, 0, 0, 0, false, false, false, false, 0, target); target.dispatchEvent(evt); - }.bind(this) ); + }.bind(this) ); }, /*引数で指定した要素 ele の属性を解析して、フレームに追加する*/ -- 2.11.0