diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-06 13:48:05 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-06 13:48:05 +0100 |
commit | a0b13ebcacfd74b9f521110c7225bb404325bcd3 (patch) | |
tree | a07c5cc422645e31d7dfef81ce4e54f03f0945f6 /src/elements/Stop.js | |
parent | 9f2696e8a2cf7e4eebc1cc7e31027fe2070094fa (diff) | |
download | svg.js-a0b13ebcacfd74b9f521110c7225bb404325bcd3.tar.gz svg.js-a0b13ebcacfd74b9f521110c7225bb404325bcd3.zip |
reordered modules, add es6 build
Diffstat (limited to 'src/elements/Stop.js')
-rw-r--r-- | src/elements/Stop.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/elements/Stop.js b/src/elements/Stop.js new file mode 100644 index 0000000..bf919e8 --- /dev/null +++ b/src/elements/Stop.js @@ -0,0 +1,29 @@ +import { nodeOrNew, register } from '../utils/adopter.js' +import Element from './Element.js' +import SVGNumber from '../types/SVGNumber.js' + +export default class Stop extends Element { + constructor (node) { + super(nodeOrNew('stop', node), Stop) + } + + // add color stops + update (o) { + if (typeof o === 'number' || o instanceof SVGNumber) { + o = { + offset: arguments[0], + color: arguments[1], + opacity: arguments[2] + } + } + + // set attributes + if (o.opacity != null) this.attr('stop-opacity', o.opacity) + if (o.color != null) this.attr('stop-color', o.color) + if (o.offset != null) this.attr('offset', new SVGNumber(o.offset)) + + return this + } +} + +register(Stop) |