return;
}
var tar = evt.target,
- name = evt.attrName;
+ name = evt.attrName,
+ timing = function(val, name) {
+ /*timing関数は時間のタイミングをidとeventと、clock-value(offset)に分割して処理していく
+ *まず、idを検出するためのsearcIdローカル関数を作る
+ */
+ var offset = 0,
+ searchId = function () {
+ var n = val.indexOf(".");
+ if ((n > 0) && val.charAt(n+1).test(/[a-z]/i)) { //. (dot)の後がアルファベットならば
+ return (val.slice(0, n));
+ }
+ n = nn = void 0;
+ return "";
+ },
+ _tar = tar,
+ id;
+ /*offsetの計算*/
+ var n = parseFloat(val.match(_tar._timeRegExp));
+ if (isFinite(n) && RegExp.$1) {
+ offset = n * _tar._unit[RegExp.$1]
+ } else if (isFinite(n)) {
+ offset = n;
+ }
+ /*
+ *W3CのSMIl AnimationのTimingモデルは7パターンがあるので、場合分けする
+ */
+ if (isFinite(parseFloat(val))) { //1) offset-valueの場合
+ _tar[name](offset);
+ } else if (val.indexOf("repeat(") > -1) { //2) repeat-valueの場合
+ n = 0;
+ var inte = parseFloat(val.slice(7)),
+ ds = function (evt) {
+ ++n;
+ if (inte === n) {
+ _tar[name](offset);
+ }
+ };
+ id = searchId();
+ if (id) {
+ _tar.ownerDocument.getElementById(id).addEventListener("repeat", ds);
+ } else {
+ _tar.addEventListener("repeat", ds);
+ }
+ } else if (val.test(/\.(begin|end)/)) { //3) syncbase-valueの場合
+ id = searchId();
+ if (id) {
+ var ds = function (evt) {
+ _tar[name](offset);
+ },
+ ev = "";
+ if (RegExp.$1 === "begin") {
+ ev = "beginEvent";
+ } else if (RegExp.$1 === "end") {
+ ev = "endEvent";
+ }
+ _tar.ownerDocument.getElementById(id).addEventListener(ev, ds);
+ }
+ } else if (val.indexOf("wallclock(") === 0) { //4) wallclock-valueの場合
+
+ } else if (val === "indefinte") { //5) indefinteの場合
+ } else if (val.indexOf("accesskey(") > -1) { //6) accesskey-valueの場合
+
+ } else { //7) event-valueの場合
+ id = searchId();
+ var ds = function (evt) {
+ _tar[name](offset);
+ };
+ if (id && val.match(new RegExp(id+"\.([a-zA-Z]+)"))) {
+ _tar.ownerDocument.getElementById(id).addEventListener(RegExp.$1, ds);
+ } else {
+ _tar.targetElement.addEventListener(val.match(/^[a-z]+/i), ds)
+ }
+ }
+ };
if (name === "begin") {
tar._beginValue = evt.newValue;
+ timing(evt.newValue, "beginEvent");
} else if (name === "end") {
tar._endValue = evt.newValue;
+ timing(evt.newValue, "endEvent");
} else if (name === "dur") {
tar._simpleDuration = tar._getOffset(evt.newValue);
} else if (name === "repeatCount") {
this._end = offset + ntc;
};
SVGAnimationElement.prototype._eventRegExp = /(mouse|activ|clic|begi|en)[a-z]+/;
-SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?/;
+SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?$/;
SVGAnimationElement.prototype._unit = {
"h" : 2880000,
"min" : 48000,