aboutsummaryrefslogtreecommitdiffstats
path: root/src/elements/Mask.js
diff options
context:
space:
mode:
authorSaivan <savian@me.com>2018-11-25 16:21:53 +1300
committerSaivan <savian@me.com>2018-11-25 16:21:53 +1300
commit62de7d0a1b994b69032a759b796b486e6bc382e3 (patch)
tree112b19f2903b4dc5b4cf61ebef0d021c6ca2f14d /src/elements/Mask.js
parent2b37d7ba5b4267b39c86f9aba5fb14a1b376e846 (diff)
downloadsvg.js-62de7d0a1b994b69032a759b796b486e6bc382e3.tar.gz
svg.js-62de7d0a1b994b69032a759b796b486e6bc382e3.zip
Changed the esLint rules to avoid silly ternary operators, and to let code breathe!
This commit modifies some of the eslint rules, to allow our code to be a little bit more readable. This came about because we had a particularly pesky problem, where the code was indenting ternary operators. This fixes that, and makes it easy to add new rules to eslint as we please in the future. Changes ======= - Rebuilt the library with new eslint rules - Changed the eslintrc file to a yaml file by default
Diffstat (limited to 'src/elements/Mask.js')
-rw-r--r--src/elements/Mask.js50
1 files changed, 34 insertions, 16 deletions
diff --git a/src/elements/Mask.js b/src/elements/Mask.js
index 8dfffd6..523b9de 100644
--- a/src/elements/Mask.js
+++ b/src/elements/Mask.js
@@ -4,54 +4,72 @@ import Container from './Container.js'
import baseFind from '../modules/core/selector.js'
export default class Mask extends Container {
+
// Initialize node
- constructor (node) {
- super(nodeOrNew('mask', node), node)
+ constructor ( node ) {
+
+ super( nodeOrNew( 'mask', node ), node )
+
}
// Unmask all masked elements and remove itself
remove () {
+
// unmask all targets
- this.targets().forEach(function (el) {
+ this.targets().forEach( function ( el ) {
+
el.unmask()
- })
+
+ } )
// remove mask from parent
return super.remove()
+
}
targets () {
- return baseFind('svg [mask*="' + this.id() + '"]')
+
+ return baseFind( 'svg [mask*="' + this.id() + '"]' )
+
}
+
}
-registerMethods({
+registerMethods( {
Container: {
- mask: wrapWithAttrCheck(function () {
- return this.defs().put(new Mask())
- })
+ mask: wrapWithAttrCheck( function () {
+
+ return this.defs().put( new Mask() )
+
+ } )
},
Element: {
// Distribute mask to svg element
- maskWith (element) {
+ maskWith ( element ) {
+
// use given mask or create a new one
var masker = element instanceof Mask
? element
- : this.parent().mask().add(element)
+ : this.parent().mask().add( element )
// apply mask
- return this.attr('mask', 'url("#' + masker.id() + '")')
+ return this.attr( 'mask', 'url("#' + masker.id() + '")' )
+
},
// Unmask element
unmask () {
- return this.attr('mask', null)
+
+ return this.attr( 'mask', null )
+
},
masker () {
- return this.reference('mask')
+
+ return this.reference( 'mask' )
+
}
}
-})
+} )
-register(Mask)
+register( Mask )