diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-10-18 12:37:55 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-10-18 12:37:55 +0200 |
commit | f46aedf58fbc93483cb21017ffed10e439830108 (patch) | |
tree | 2633bc1034a4fceaca977f45ef386ecc07abe519 /src | |
parent | e9ec77f512b01f067b20e037385f4e8074cb4bdb (diff) | |
download | svg.js-f46aedf58fbc93483cb21017ffed10e439830108.tar.gz svg.js-f46aedf58fbc93483cb21017ffed10e439830108.zip |
fix tests
Diffstat (limited to 'src')
-rw-r--r-- | src/event.js | 33 | ||||
-rw-r--r-- | src/eventtarget.js | 23 | ||||
-rw-r--r-- | src/number.js | 10 | ||||
-rw-r--r-- | src/runner.js | 31 |
4 files changed, 28 insertions, 69 deletions
diff --git a/src/event.js b/src/event.js index 64a791c..4f16609 100644 --- a/src/event.js +++ b/src/event.js @@ -1,5 +1,4 @@ // Add events to elements -/* ;[ 'click', 'dblclick', 'mousedown', @@ -16,12 +15,14 @@ 'touchcancel' ].forEach(function (event) { // add event to SVG.Element SVG.Element.prototype[event] = function (f) { - // bind event to element rather than element node - SVG.on(this, event, f) + if (f === null) { + SVG.off(this, event) + } else { + SVG.on(this, event, f) + } return this } }) -*/ SVG.listenerId = 0 @@ -132,27 +133,3 @@ SVG.dispatch = function (node, event, data) { } return event } - -SVG.EventTarget = SVG.invent({ - create: function () {}, - extend: { - // Bind given event to listener - on: function (event, listener, binding, options) { - SVG.on(this, event, listener, binding, options) - return this - }, - // Unbind event from listener - off: function (event, listener) { - SVG.off(this, event, listener) - return this - }, - dispatch: function (event, data) { - return SVG.dispatch(this, event, data) - }, - // Fire given event - fire: function (event, data) { - this.dispatch(event, data) - return this - } - } -}) diff --git a/src/eventtarget.js b/src/eventtarget.js new file mode 100644 index 0000000..fbe4781 --- /dev/null +++ b/src/eventtarget.js @@ -0,0 +1,23 @@ +SVG.EventTarget = SVG.invent({ + create: function () {}, + extend: { + // Bind given event to listener + on: function (event, listener, binding, options) { + SVG.on(this, event, listener, binding, options) + return this + }, + // Unbind event from listener + off: function (event, listener) { + SVG.off(this, event, listener) + return this + }, + dispatch: function (event, data) { + return SVG.dispatch(this, event, data) + }, + // Fire given event + fire: function (event, data) { + this.dispatch(event, data) + return this + } + } +}) diff --git a/src/number.js b/src/number.js index 7fef7f2..2135b61 100644 --- a/src/number.js +++ b/src/number.js @@ -74,16 +74,6 @@ SVG.Number = SVG.invent({ number = new SVG.Number(number) return new SVG.Number(this / number, this.unit || number.unit) }, - // Convert to different unit - to: function (unit) { - var number = new SVG.Number(this) - - if (typeof unit === 'string') { - number.unit = unit - } - - return number - }, // Make number morphable morph: function (number) { this.destination = new SVG.Number(number) diff --git a/src/runner.js b/src/runner.js index 41280a0..97e04e2 100644 --- a/src/runner.js +++ b/src/runner.js @@ -42,7 +42,6 @@ SVG.Runner = SVG.invent({ this.enabled = true this._time = 0 this._last = 0 - this.tags = {} // Save transforms applied to this runner this.transforms = new SVG.Matrix() @@ -325,36 +324,6 @@ SVG.Runner = SVG.invent({ }, /* - Runner Management - ================= - Functions that are used to help index the runner - */ - - tag: function (name) { - // Act as a getter to get all of the tags on this object - if (name == null) return Object.keys(this.tags) - - // Add all of the tags to the object directly - name = Array.isArray(name) ? name : [name] - for (var i = name.length; i--;) { - this.tags[name[i]] = true - } - return this - }, - - untag: function (name) { - name = Array.isArray(name) ? name : [name] - for (var i = name.length; i--;) { - delete this.tags[name[i]] - } - return this - }, - - getEventTarget: function () { - return this._dispatcher - }, - - /* Private Methods =============== Methods that shouldn't be used externally |