]> source.dussan.org Git - svg.js.git/commitdiff
changed image callback according to (#931)
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>
Sat, 17 Nov 2018 10:09:39 +0000 (11:09 +0100)
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>
Sat, 17 Nov 2018 10:09:39 +0000 (11:09 +0100)
CHANGELOG.md
dist/svg.js
spec/spec/image.js
src/elements/Dom.js
src/elements/Image.js
src/modules/core/selector.js

index b9b35d046ce95c4831c5769ae8546d5db0ab73e4..87c12f851e90f6a1c30e44ea40d5f464a4f29143 100644 (file)
@@ -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!__
index ab443a740da73f8daab7cc5ee1ae06cea923d395..4cb967f6c0c1b4fdcc0d8196e3663421fe6da220 100644 (file)
@@ -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
index f5de8939262a473f8b1cc1e15bef0c2c2909a096..589116d69c031df17a10d47f07fce1b663da8187 100644 (file)
@@ -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))
     })
   })
 })
index 08084433f41def937d55969d2f47398a6a63c7a2..2fcedce0341a826aa9ae7c6dd8866f694a233b05 100644 (file)
@@ -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'
index 7f009807b82ec95c2616cbf202a2c6017bfccf8b..bf2de0ecd1f0272cef4258c480b6b17626fb3f1e 100644 (file)
@@ -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)
 
index 6fcf05ecadfd4026fc8a93bda1232f1c4ae7f373..24841c557e8cb95a66a91648d1b13e0fb84e4cb7 100644 (file)
@@ -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) {