aboutsummaryrefslogtreecommitdiffstats
path: root/dist/svg.js
diff options
context:
space:
mode:
Diffstat (limited to 'dist/svg.js')
-rw-r--r--dist/svg.js57
1 files changed, 20 insertions, 37 deletions
diff --git a/dist/svg.js b/dist/svg.js
index b52b6de..a71d957 100644
--- a/dist/svg.js
+++ b/dist/svg.js
@@ -6,7 +6,7 @@
* @copyright Wout Fierens <wout@mick-wout.com>
* @license MIT
*
-* BUILT: Sun Mar 19 2017 14:06:32 GMT+0100 (Mitteleuropäische Zeit)
+* BUILT: Sun Mar 19 2017 16:34:53 GMT+0100 (Mitteleuropäische Zeit)
*/;
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
@@ -2457,7 +2457,7 @@ SVG.extend(SVG.Element, {
// convert image fill and stroke to patterns
if (a == 'fill' || a == 'stroke') {
if (SVG.regex.isImage.test(v))
- v = this.doc().defs().image(v, 0, 0)
+ v = this.doc().defs().image(v)
if (v instanceof SVG.Image)
v = this.doc().defs().pattern(0, 0, function() {
@@ -4039,65 +4039,48 @@ SVG.Image = SVG.invent({
// Add class methods
, extend: {
// (re)load image
- load: function(url) {
+ load: function(url, callback) {
if (!url) return this
- var self = this
- , img = new window.Image()
+ var img = new window.Image()
- // preload image
- img.onload = function() {
- var p = self.parent(SVG.Pattern)
+ SVG.on(img, 'load', function(e) {
- if(p === null) return
+ var p = this.parent()
// ensure image size
- if (self.width() == 0 && self.height() == 0)
- self.size(img.width, img.height)
+ if (this.width() == 0 && this.height() == 0)
+ this.size(img.width, img.height)
- // ensure pattern size if not set
- if (p && p.width() == 0 && p.height() == 0)
- p.size(self.width(), self.height())
+ if(p instanceof SVG.Pattern) {
+ // ensure pattern size if not set
+ if (p.width() == 0 && p.height() == 0)
+ p.size(this.width(), this.height())
+ }
- // callback
- if (typeof self._loaded === 'function')
- self._loaded.call(self, {
+ if(typeof callback == 'function') {
+ callback.call(this, {
width: img.width
, height: img.height
, ratio: img.width / img.height
, url: url
})
- }
-
- img.onerror = function(e){
- if (typeof self._error === 'function'){
- self._error.call(self, e)
}
- }
+ }, this)
- return this.attr('href', (img.src = this.src = url), SVG.xlink)
- }
- // Add loaded callback
- , loaded: function(loaded) {
- this._loaded = loaded
- return this
- }
-
- , error: function(error) {
- this._error = error
- return this
+ return this.attr('href', (img.src = url), SVG.xlink)
}
}
// Add parent method
, construct: {
// create image element, load image and set its size
- image: function(source, width, height) {
- return this.put(new SVG.Image).load(source).size(width || 0, height || width || 0)
+ image: function(source, callback) {
+ return this.put(new SVG.Image).size(0, 0).load(source, callback)
}
}
-
})
+
SVG.Text = SVG.invent({
// Initialize node
create: function() {