aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-17 11:09:39 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-17 11:09:39 +0100
commitd5a8faa4d06d2664a7748ea570937751ef5271d5 (patch)
treed67a029d75753e20a069e8975ee0753f4ea65c71
parent079f6f0ac37cb6d62501e8c397cc9850936f26e6 (diff)
downloadsvg.js-d5a8faa4d06d2664a7748ea570937751ef5271d5.tar.gz
svg.js-d5a8faa4d06d2664a7748ea570937751ef5271d5.zip
changed image callback according to (#931)
-rw-r--r--CHANGELOG.md1
-rw-r--r--dist/svg.js203
-rw-r--r--spec/spec/image.js7
-rw-r--r--src/elements/Dom.js2
-rw-r--r--src/elements/Image.js7
-rw-r--r--src/modules/core/selector.js1
6 files changed, 102 insertions, 119 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b9b35d0..87c12f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -83,6 +83,7 @@ The document follows the conventions described in [“Keep a CHANGELOG”](http:
- `SVG.Text.rebuild()` now takes every font-size into account (#512)
- `fill()` and `stroke()` return the fill and stroke attribute when called as getter (#789)
- `parents()` now gives back all parents until the passed one or document
+- `Image` callback passes normal `load` event instead of custom object (#931)
### Fixed
- fixed a bug in clipping and masking where empty nodes persists after removal -> __TODO!__
diff --git a/dist/svg.js b/dist/svg.js
index ab443a7..4cb967f 100644
--- a/dist/svg.js
+++ b/dist/svg.js
@@ -6,7 +6,7 @@
* @copyright Wout Fierens <wout@mick-wout.com>
* @license MIT
*
-* BUILT: Mon Nov 12 2018 14:48:34 GMT+0100 (GMT+01:00)
+* BUILT: Sat Nov 17 2018 10:54:31 GMT+0100 (GMT+01:00)
*/;
var SVG = (function () {
'use strict';
@@ -1832,89 +1832,6 @@ var SVG = (function () {
return new Matrix(this.node.getScreenCTM());
}
- var EventTarget =
- /*#__PURE__*/
- function (_Base) {
- _inherits(EventTarget, _Base);
-
- function EventTarget() {
- var _this;
-
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- _ref$events = _ref.events,
- events = _ref$events === void 0 ? {} : _ref$events;
-
- _classCallCheck(this, EventTarget);
-
- _this = _possibleConstructorReturn(this, _getPrototypeOf(EventTarget).call(this));
- _this.events = events;
- return _this;
- }
-
- _createClass(EventTarget, [{
- key: "addEventListener",
- value: function addEventListener() {} // Bind given event to listener
-
- }, {
- key: "on",
- value: function on$$1(event, listener, binding, options) {
- on(this, event, listener, binding, options);
-
- return this;
- } // Unbind event from listener
-
- }, {
- key: "off",
- value: function off$$1(event, listener) {
- off(this, event, listener);
-
- return this;
- }
- }, {
- key: "dispatch",
- value: function dispatch$$1(event, data) {
- return dispatch(this, event, data);
- }
- }, {
- key: "dispatchEvent",
- value: function dispatchEvent(event) {
- var bag = this.getEventHolder().events;
- if (!bag) return true;
- var events = bag[event.type];
-
- for (var i in events) {
- for (var j in events[i]) {
- events[i][j](event);
- }
- }
-
- return !event.defaultPrevented;
- } // Fire given event
-
- }, {
- key: "fire",
- value: function fire(event, data) {
- this.dispatch(event, data);
- return this;
- }
- }, {
- key: "getEventHolder",
- value: function getEventHolder() {
- return this;
- }
- }, {
- key: "getEventTarget",
- value: function getEventTarget() {
- return this;
- }
- }, {
- key: "removeEventListener",
- value: function removeEventListener() {}
- }]);
-
- return EventTarget;
- }(Base);
-
/* eslint no-new-func: "off" */
var subClassArray = function () {
try {
@@ -1991,6 +1908,99 @@ var SVG = (function () {
extend(List, methods);
};
+ function baseFind(query, parent) {
+ return new List(map((parent || globals.document).querySelectorAll(query), function (node) {
+ return adopt(node);
+ }));
+ } // Scoped find method
+
+ function find(query) {
+ return baseFind(query, this.node);
+ }
+
+ var EventTarget =
+ /*#__PURE__*/
+ function (_Base) {
+ _inherits(EventTarget, _Base);
+
+ function EventTarget() {
+ var _this;
+
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
+ _ref$events = _ref.events,
+ events = _ref$events === void 0 ? {} : _ref$events;
+
+ _classCallCheck(this, EventTarget);
+
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(EventTarget).call(this));
+ _this.events = events;
+ return _this;
+ }
+
+ _createClass(EventTarget, [{
+ key: "addEventListener",
+ value: function addEventListener() {}
+ }, {
+ key: "dispatch",
+ value: function dispatch$$1(event, data) {
+ return dispatch(this, event, data);
+ }
+ }, {
+ key: "dispatchEvent",
+ value: function dispatchEvent(event) {
+ var bag = this.getEventHolder().events;
+ if (!bag) return true;
+ var events = bag[event.type];
+
+ for (var i in events) {
+ for (var j in events[i]) {
+ events[i][j](event);
+ }
+ }
+
+ return !event.defaultPrevented;
+ } // Fire given event
+
+ }, {
+ key: "fire",
+ value: function fire(event, data) {
+ this.dispatch(event, data);
+ return this;
+ }
+ }, {
+ key: "getEventHolder",
+ value: function getEventHolder() {
+ return this;
+ }
+ }, {
+ key: "getEventTarget",
+ value: function getEventTarget() {
+ return this;
+ } // Unbind event from listener
+
+ }, {
+ key: "off",
+ value: function off$$1(event, listener) {
+ off(this, event, listener);
+
+ return this;
+ } // Bind given event to listener
+
+ }, {
+ key: "on",
+ value: function on$$1(event, listener, binding, options) {
+ on(this, event, listener, binding, options);
+
+ return this;
+ }
+ }, {
+ key: "removeEventListener",
+ value: function removeEventListener() {}
+ }]);
+
+ return EventTarget;
+ }(Base);
+
function noop() {} // Default animation values
var timeline = {
@@ -2574,7 +2584,8 @@ var SVG = (function () {
return Dom;
}(EventTarget);
extend(Dom, {
- attr: attr
+ attr: attr,
+ find: find
});
register(Dom);
@@ -3308,19 +3319,6 @@ var SVG = (function () {
}(Element);
register(Stop);
- function baseFind(query, parent) {
- return new List(map((parent || globals.document).querySelectorAll(query), function (node) {
- return adopt(node);
- }));
- } // Scoped find method
-
- function find(query) {
- return baseFind(query, this.node);
- }
- registerMethods('Dom', {
- find: find
- });
-
function from(x, y) {
return (this._element || this).type === 'radialGradient' ? this.attr({
fx: new SVGNumber(x),
@@ -3538,12 +3536,7 @@ var SVG = (function () {
}
if (typeof callback === 'function') {
- callback.call(this, {
- width: img.width,
- height: img.height,
- ratio: img.width / img.height,
- url: url
- });
+ callback.call(this, e);
}
}, this);
on(img, 'load error', function () {
@@ -3922,7 +3915,7 @@ var SVG = (function () {
}
};
},
- // https://www.w3.org/TR/css-easing-1/#step-timing-function-algo
+ // see https://www.w3.org/TR/css-easing-1/#step-timing-function-algo
steps: function steps(_steps) {
var stepPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'end';
// deal with "jump-" prefix
diff --git a/spec/spec/image.js b/spec/spec/image.js
index f5de893..589116d 100644
--- a/spec/spec/image.js
+++ b/spec/spec/image.js
@@ -32,12 +32,7 @@ describe('Image', function() {
expect(img.load()).toBe(img)
})
it('executes the load callback', function() {
- expect(loadCb.cb).toHaveBeenCalledWith({
- width: 1,
- height: 1,
- ratio: 1,
- url: jasmine.any(String)
- })
+ expect(loadCb.cb).toHaveBeenCalledWith(jasmine.any(Event))
})
})
})
diff --git a/src/elements/Dom.js b/src/elements/Dom.js
index 0808443..2fcedce 100644
--- a/src/elements/Dom.js
+++ b/src/elements/Dom.js
@@ -6,7 +6,7 @@ import {
makeInstance,
register
} from '../utils/adopter.js'
-import { find } from '../modules/core/selector';
+import { find } from '../modules/core/selector'
import { globals } from '../utils/window.js'
import { map } from '../utils/utils.js'
import { ns } from '../modules/core/namespaces.js'
diff --git a/src/elements/Image.js b/src/elements/Image.js
index 7f00980..bf2de0e 100644
--- a/src/elements/Image.js
+++ b/src/elements/Image.js
@@ -35,12 +35,7 @@ export default class Image extends Shape {
}
if (typeof callback === 'function') {
- callback.call(this, {
- width: img.width,
- height: img.height,
- ratio: img.width / img.height,
- url: url
- })
+ callback.call(this, e)
}
}, this)
diff --git a/src/modules/core/selector.js b/src/modules/core/selector.js
index 6fcf05e..24841c5 100644
--- a/src/modules/core/selector.js
+++ b/src/modules/core/selector.js
@@ -1,7 +1,6 @@
import { adopt } from '../../utils/adopter.js'
import { globals } from '../../utils/window.js'
import { map } from '../../utils/utils.js'
-import { registerMethods } from '../../utils/methods.js'
import List from '../../types/List.js'
export default function baseFind (query, parent) {