diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-10-27 20:43:35 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-10-27 20:43:35 +0200 |
commit | 1c75fcaf02ceb144152d59557643c6fdd7264065 (patch) | |
tree | 5184af75f2fd27ca6b81c24a06b1676d17ca2c76 /src/Gradient.js | |
parent | b1b776a710d0ce0a6259043b8ce0665e205195fa (diff) | |
download | svg.js-1c75fcaf02ceb144152d59557643c6fdd7264065.tar.gz svg.js-1c75fcaf02ceb144152d59557643c6fdd7264065.zip |
resolve circular references and make example working again
Diffstat (limited to 'src/Gradient.js')
-rw-r--r-- | src/Gradient.js | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/Gradient.js b/src/Gradient.js index da76666..ab4cc4f 100644 --- a/src/Gradient.js +++ b/src/Gradient.js @@ -1,10 +1,15 @@ import Stop from './Stop.js' +import Base from './Base.js' import * as gradiented from './gradiented.js' -import {nodeOrNew, extend, addFactory} from './tools.js' +import {nodeOrNew, extend} from './tools.js' +import attr from './attr.js' -export default class Gradient extends Container { +export default class Gradient extends Base { constructor (type) { - super(nodeOrNew(type + 'Gradient', typeof type === 'string' ? null : type)) + super( + nodeOrNew(type + 'Gradient', typeof type === 'string' ? null : type), + Gradient + ) } // Add a color stop @@ -38,23 +43,23 @@ export default class Gradient extends Container { // custom attr to handle transform attr (a, b, c) { if (a === 'transform') a = 'gradientTransform' - return super.attr(a, b, c) + return attr.call(this, a, b, c) } } extend(Gradient, gradiented) -addFactory(Parent, { - // Create gradient element in defs - gradient (type, block) { - return this.defs().gradient(type, block) - } -}) - -// Base gradient generation -addFactory(Defs, { +Gradient.constructors = { + Container: { + // Create gradient element in defs + gradient (type, block) { + return this.defs().gradient(type, block) + } + }, // define gradient - gradient: function (type, block) { - return this.put(new Gradient(type)).update(block) + Defs: { + gradient (type, block) { + return this.put(new Gradient(type)).update(block) + } } -}) +} |