feat(core): Added new utility methods for attrs
This commit is contained in:
parent
21434ed2f6
commit
50b37f4cb5
3 changed files with 39 additions and 0 deletions
|
@ -359,4 +359,20 @@ Part.prototype.generateTransform = function(transforms) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Chainable way to set the grain property */
|
||||||
|
Part.prototype.setGrain = function (grain = 90) {
|
||||||
|
this.attributes.set('data-grain', grain)
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Chainable way to set the grain property */
|
||||||
|
Part.prototype.setCut = function (cut = { count: 2, mirror: true, onFold: false }) {
|
||||||
|
this.attributes.set('data-cut', cut)
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default Part
|
export default Part
|
||||||
|
|
|
@ -35,6 +35,13 @@ Path.prototype.setRender = function (render = true) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Chainable way to set the class property */
|
||||||
|
Path.prototype.setClass = function (className = false) {
|
||||||
|
if (className) this.attributes.set('class', className)
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
/** Adds a move operation to Point to */
|
/** Adds a move operation to Point to */
|
||||||
Path.prototype.move = function (to) {
|
Path.prototype.move = function (to) {
|
||||||
if (to instanceof Point !== true)
|
if (to instanceof Point !== true)
|
||||||
|
|
|
@ -231,4 +231,20 @@ Point.prototype.translate = function (x, y) {
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Chainable way to set the data-text property (and optional class) */
|
||||||
|
Point.prototype.setText = function (text = '', className=false) {
|
||||||
|
this.attributes.set('data-text', text)
|
||||||
|
if (className) this.attributes.set('data-text-class', className)
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Chainable way to set the data-circle property (and optional class) */
|
||||||
|
Point.prototype.setCircle = function (radius = false, className=false) {
|
||||||
|
if (radius) this.attributes.set('data-circle', radius)
|
||||||
|
if (className) this.attributes.set('data-circle-class', className)
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
export default Point
|
export default Point
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue