diff options
author | Saivan <savian@me.com> | 2018-11-26 00:17:41 +1300 |
---|---|---|
committer | Saivan <savian@me.com> | 2018-11-26 00:17:41 +1300 |
commit | 617aa12304541cf1d80b2bf5567ac633958c38de (patch) | |
tree | c1082b4573625f93d18e82e6d5a0c4a40782993f /src/elements/Element.js | |
parent | 599fda2f11c88b2c18d0cd0b57d4adeca20db2eb (diff) | |
download | svg.js-617aa12304541cf1d80b2bf5567ac633958c38de.tar.gz svg.js-617aa12304541cf1d80b2bf5567ac633958c38de.zip |
Reverted some of the lint rules after chatting with fuzzy
This commit reverts some of the rules we added on the linter, it changed a lot of
code again... but these won't happen too often.
Changes
=======
- Modified the linter again
Diffstat (limited to 'src/elements/Element.js')
-rw-r--r-- | src/elements/Element.js | 130 |
1 files changed, 43 insertions, 87 deletions
diff --git a/src/elements/Element.js b/src/elements/Element.js index 169c872..594daa1 100644 --- a/src/elements/Element.js +++ b/src/elements/Element.js @@ -15,13 +15,11 @@ import Dom from './Dom.js' import List from '../types/List.js' import SVGNumber from '../types/SVGNumber.js' -const Svg = getClass( root ) +const Svg = getClass(root) export default class Element extends Dom { - - constructor ( node, attrs ) { - - super( node, attrs ) + constructor (node, attrs) { + super(node, attrs) // initialize data object this.dom = {} @@ -29,177 +27,135 @@ export default class Element extends Dom { // create circular reference this.node.instance = this - if ( node.hasAttribute( 'svgjs:data' ) ) { - + if (node.hasAttribute('svgjs:data')) { // pull svgjs data from the dom (getAttributeNS doesn't work in html5) - this.setData( JSON.parse( node.getAttribute( 'svgjs:data' ) ) || {} ) - + this.setData(JSON.parse(node.getAttribute('svgjs:data')) || {}) } - } // Move element by its center - center ( x, y ) { - - return this.cx( x ).cy( y ) - + center (x, y) { + return this.cx(x).cy(y) } // Move by center over x-axis - cx ( x ) { - - return x == null ? this.x() + this.width() / 2 : this.x( x - this.width() / 2 ) - + cx (x) { + return x == null ? this.x() + this.width() / 2 : this.x(x - this.width() / 2) } // Move by center over y-axis - cy ( y ) { - + cy (y) { return y == null ? this.y() + this.height() / 2 - : this.y( y - this.height() / 2 ) - + : this.y(y - this.height() / 2) } // Get defs defs () { - return this.root().defs() - } // Get parent document root () { - - let p = this.parent( Svg ) + let p = this.parent(Svg) return p && p.root() - } getEventHolder () { - return this - } // Set height of element - height ( height ) { - - return this.attr( 'height', height ) - + height (height) { + return this.attr('height', height) } // Checks whether the given point inside the bounding box of the element - inside ( x, y ) { - + inside (x, y) { let box = this.bbox() return x > box.x && y > box.y && x < box.x + box.width && y < box.y + box.height - } // Move element to given x and y values - move ( x, y ) { - - return this.x( x ).y( y ) - + move (x, y) { + return this.x(x).y(y) } // return array of all ancestors of given type up to the root svg - parents ( until = globals.document ) { - - until = makeInstance( until ) + parents (until = globals.document) { + until = makeInstance(until) let parents = new List() let parent = this while ( - ( parent = parent.parent() ) + (parent = parent.parent()) && parent.node !== until.node && parent.node !== globals.document ) { - - parents.push( parent ) - + parents.push(parent) } return parents - } // Get referenced element form attribute value - reference ( attr ) { - - attr = this.attr( attr ) - if ( !attr ) return null - - const m = attr.match( reference ) - return m ? makeInstance( m[1] ) : null + reference (attr) { + attr = this.attr(attr) + if (!attr) return null + const m = attr.match(reference) + return m ? makeInstance(m[1]) : null } // set given data to the elements data property - setData ( o ) { - + setData (o) { this.dom = o return this - } // Set element size to given width and height - size ( width, height ) { - - let p = proportionalSize( this, width, height ) + size (width, height) { + let p = proportionalSize(this, width, height) return this - .width( new SVGNumber( p.width ) ) - .height( new SVGNumber( p.height ) ) - + .width(new SVGNumber(p.width)) + .height(new SVGNumber(p.height)) } // Set width of element - width ( width ) { - - return this.attr( 'width', width ) - + width (width) { + return this.attr('width', width) } // write svgjs data to the dom writeDataToDom () { - // remove previously set data - this.node.removeAttribute( 'svgjs:data' ) - - if ( Object.keys( this.dom ).length ) { - - this.node.setAttribute( 'svgjs:data', JSON.stringify( this.dom ) ) // see #428 + this.node.removeAttribute('svgjs:data') + if (Object.keys(this.dom).length) { + this.node.setAttribute('svgjs:data', JSON.stringify(this.dom)) // see #428 } return super.writeDataToDom() - } // Move over x-axis - x ( x ) { - - return this.attr( 'x', x ) - + x (x) { + return this.attr('x', x) } // Move over y-axis - y ( y ) { - - return this.attr( 'y', y ) - + y (y) { + return this.attr('y', y) } - } -extend( Element, { +extend(Element, { bbox, rbox, point, ctm, screenCTM -} ) +}) -register( Element ) +register(Element) |