1
0
Fork 0

feat(core): Do not render snippets by default when complete is false

This commit is contained in:
joostdecock 2023-09-06 08:57:43 +02:00
parent 9f081eebb1
commit 8de63bb446
2 changed files with 6 additions and 1 deletions

View file

@ -11,13 +11,16 @@ import { Point } from './point.mjs'
* @constructor
* @param {string} def - The id of the snippet in the SVG defs section
* @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
*/
export function Snippet(def, anchor) {
export function Snippet(def, anchor, force = false) {
this.def = def
this.anchor = anchor
this.attributes = new Attributes()
if (force) this.attributes.set('data-force', 1)
return this
}

View file

@ -336,6 +336,8 @@ Svg.prototype.__renderPart = function (part) {
* @return {string} svg - The SVG markup for the 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 y = round(snippet.anchor.y)
let scale = snippet.attributes.get('data-scale') || 1