feat(core): Do not render snippets by default when complete is false
This commit is contained in:
parent
9f081eebb1
commit
8de63bb446
2 changed files with 6 additions and 1 deletions
|
@ -11,13 +11,16 @@ import { Point } from './point.mjs'
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {string} def - The id of the snippet in the SVG defs section
|
* @param {string} def - The id of the snippet in the SVG defs section
|
||||||
* @param {Point} anchor - The Point to anchor this Snippet on
|
* @param {Point} anchor - The Point to anchor this Snippet on
|
||||||
|
* @param {boolean} force - Whether to force rendering of this snippet when complete is falsy (or not)
|
||||||
* @return {Snippet} this - The Snippet instance
|
* @return {Snippet} this - The Snippet instance
|
||||||
*/
|
*/
|
||||||
export function Snippet(def, anchor) {
|
export function Snippet(def, anchor, force = false) {
|
||||||
this.def = def
|
this.def = def
|
||||||
this.anchor = anchor
|
this.anchor = anchor
|
||||||
this.attributes = new Attributes()
|
this.attributes = new Attributes()
|
||||||
|
|
||||||
|
if (force) this.attributes.set('data-force', 1)
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -336,6 +336,8 @@ Svg.prototype.__renderPart = function (part) {
|
||||||
* @return {string} svg - The SVG markup for the snippet
|
* @return {string} svg - The SVG markup for the snippet
|
||||||
*/
|
*/
|
||||||
Svg.prototype.__renderSnippet = function (snippet) {
|
Svg.prototype.__renderSnippet = function (snippet) {
|
||||||
|
// If complete is not set, only render snippets with the data-force attribute
|
||||||
|
if (!this.pattern.settings[0].complete && !snippet.attributes.get('data-force')) return ''
|
||||||
let x = round(snippet.anchor.x)
|
let x = round(snippet.anchor.x)
|
||||||
let y = round(snippet.anchor.y)
|
let y = round(snippet.anchor.y)
|
||||||
let scale = snippet.attributes.get('data-scale') || 1
|
let scale = snippet.attributes.get('data-scale') || 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue