summaryrefslogtreecommitdiffstats
path: root/src/types
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-11 17:37:06 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-11 17:37:06 +0100
commitbf7703f5915c6154937f3febf812aad6483bff45 (patch)
tree384be2f9fff05e755669b14f2f8fa0a624dacf45 /src/types
parentf2513baf3c9262190ee2c92fb98b2dd099bfbab2 (diff)
downloadsvg.js-bf7703f5915c6154937f3febf812aad6483bff45.tar.gz
svg.js-bf7703f5915c6154937f3febf812aad6483bff45.zip
make window and document exchangeable in case they are not globals alreay, make sure that init functions are chaninable
Diffstat (limited to 'src/types')
-rw-r--r--src/types/Box.js5
-rw-r--r--src/types/Color.js2
-rw-r--r--src/types/Matrix.js2
-rw-r--r--src/types/Morphable.js3
-rw-r--r--src/types/Point.js2
-rw-r--r--src/types/SVGArray.js1
-rw-r--r--src/types/SVGNumber.js2
7 files changed, 17 insertions, 0 deletions
diff --git a/src/types/Box.js b/src/types/Box.js
index 21672b1..97ba699 100644
--- a/src/types/Box.js
+++ b/src/types/Box.js
@@ -1,8 +1,11 @@
import { delimiter } from '../modules/core/regex.js'
import { registerMethods } from '../utils/methods.js'
+import globals from '../utils/window.js'
import Point from './Point.js'
import parser from '../modules/core/parser.js'
+const { window, document } = globals
+
function isNulledBox (box) {
return !box.w && !box.h && !box.x && !box.y
}
@@ -41,6 +44,8 @@ export default class Box {
this.y2 = this.y + this.h
this.cx = this.x + this.w / 2
this.cy = this.y + this.h / 2
+
+ return this
}
// Merge rect box with another, return a new instance
diff --git a/src/types/Color.js b/src/types/Color.js
index 6bbfd82..a96958b 100644
--- a/src/types/Color.js
+++ b/src/types/Color.js
@@ -93,6 +93,8 @@ export default class Color {
this.g = g
this.b = b
}
+
+ return this
}
// Default to hex conversion
diff --git a/src/types/Matrix.js b/src/types/Matrix.js
index 963fd1a..ee12488 100644
--- a/src/types/Matrix.js
+++ b/src/types/Matrix.js
@@ -37,6 +37,8 @@ export default class Matrix {
this.d = source.d != null ? source.d : base.d
this.e = source.e != null ? source.e : base.e
this.f = source.f != null ? source.f : base.f
+
+ return this
}
// Clones this matrix
diff --git a/src/types/Morphable.js b/src/types/Morphable.js
index 021c5f4..703cc00 100644
--- a/src/types/Morphable.js
+++ b/src/types/Morphable.js
@@ -121,6 +121,7 @@ export class NonMorphable {
init (val) {
val = Array.isArray(val) ? val[0] : val
this.value = val
+ return this
}
valueOf () {
@@ -152,6 +153,7 @@ export class TransformBag {
}
Object.assign(this, TransformBag.defaults, obj)
+ return this
}
toArray () {
@@ -199,6 +201,7 @@ export class ObjectBag {
})
this.values = entries.reduce((last, curr) => last.concat(curr), [])
+ return this
}
valueOf () {
diff --git a/src/types/Point.js b/src/types/Point.js
index 685240b..6a2b968 100644
--- a/src/types/Point.js
+++ b/src/types/Point.js
@@ -19,6 +19,8 @@ export default class Point {
// merge source
this.x = source.x == null ? base.x : source.x
this.y = source.y == null ? base.y : source.y
+
+ return this
}
// Clone point
diff --git a/src/types/SVGArray.js b/src/types/SVGArray.js
index 3894b22..4fcb500 100644
--- a/src/types/SVGArray.js
+++ b/src/types/SVGArray.js
@@ -12,6 +12,7 @@ extend(SVGArray, {
init (arr) {
this.length = 0
this.push(...this.parse(arr))
+ return this
},
toArray () {
diff --git a/src/types/SVGNumber.js b/src/types/SVGNumber.js
index bba9741..ea21cbd 100644
--- a/src/types/SVGNumber.js
+++ b/src/types/SVGNumber.js
@@ -40,6 +40,8 @@ export default class SVGNumber {
this.unit = value.unit
}
}
+
+ return this
}
toString () {