fix lgtm warnings and other minor fixes
parent
88207acc98
commit
ff34764955
|
@ -37,7 +37,7 @@ describe('utilities bbox', function () {
|
|||
}
|
||||
const mockPathActions = {
|
||||
resetOrientation (pth) {
|
||||
if (utilities.isNullish(pth) || pth.nodeName !== 'path') { return false }
|
||||
if (pth?.nodeName !== 'path') { return false }
|
||||
const tlist = pth.transform.baseVal
|
||||
const m = math.transformListToTransform(tlist).matrix
|
||||
tlist.clear()
|
||||
|
|
|
@ -116,7 +116,7 @@ describe('utilities performance', function () {
|
|||
|
||||
const mockPathActions = {
|
||||
resetOrientation (path) {
|
||||
if (utilities.isNullish(path) || path.nodeName !== 'path') { return false }
|
||||
if (path?.nodeName !== 'path') { return false }
|
||||
const tlist = path.transform.baseVal
|
||||
const m = math.transformListToTransform(tlist).matrix
|
||||
tlist.clear()
|
||||
|
|
|
@ -102,7 +102,7 @@ class Editor extends EditorStartup {
|
|||
{
|
||||
key: ['delete/backspace', true],
|
||||
fn: () => {
|
||||
if (!isNullish(this.selectedElement) || this.multiselected) { this.svgCanvas.deleteSelectedElements() }
|
||||
if (this.selectedElement || this.multiselected) { this.svgCanvas.deleteSelectedElements() }
|
||||
}
|
||||
},
|
||||
{ key: 'a', fn: () => { this.svgCanvas.selectAllInCurrentLayer() } },
|
||||
|
@ -489,9 +489,9 @@ class Editor extends EditorStartup {
|
|||
// if this.elems[1] is present, then we have more than one element
|
||||
this.selectedElement = (elems.length === 1 || isNullish(elems[1]) ? elems[0] : null)
|
||||
this.multiselected = (elems.length >= 2 && !isNullish(elems[1]))
|
||||
if (!isNullish(this.selectedElement) && !isNode) {
|
||||
if (this.selectedElement && !isNode) {
|
||||
this.topPanel.update()
|
||||
} // if (!isNullish(elem))
|
||||
} // if (elem)
|
||||
|
||||
// Deal with pathedit mode
|
||||
this.topPanel.togglePathEditMode(isNode, elems)
|
||||
|
@ -742,7 +742,7 @@ class Editor extends EditorStartup {
|
|||
* @returns {void}
|
||||
*/
|
||||
cutSelected () {
|
||||
if (!isNullish(this.selectedElement) || this.multiselected) {
|
||||
if (this.selectedElement || this.multiselected) {
|
||||
this.svgCanvas.cutSelectedElements()
|
||||
}
|
||||
}
|
||||
|
@ -752,7 +752,7 @@ class Editor extends EditorStartup {
|
|||
* @returns {void}
|
||||
*/
|
||||
copySelected () {
|
||||
if (!isNullish(this.selectedElement) || this.multiselected) {
|
||||
if (this.selectedElement || this.multiselected) {
|
||||
this.svgCanvas.copySelectedElements()
|
||||
}
|
||||
}
|
||||
|
@ -774,7 +774,7 @@ class Editor extends EditorStartup {
|
|||
* @returns {void}
|
||||
*/
|
||||
moveUpDownSelected (dir) {
|
||||
if (!isNullish(this.selectedElement)) {
|
||||
if (this.selectedElement) {
|
||||
this.svgCanvas.moveUpDownSelected(dir)
|
||||
}
|
||||
}
|
||||
|
@ -785,7 +785,7 @@ class Editor extends EditorStartup {
|
|||
* @returns {void}
|
||||
*/
|
||||
moveSelected (dx, dy) {
|
||||
if (!isNullish(this.selectedElement) || this.multiselected) {
|
||||
if (this.selectedElement || this.multiselected) {
|
||||
if (this.configObj.curConfig.gridSnapping) {
|
||||
// Use grid snap value regardless of zoom level
|
||||
const multi = this.svgCanvas.getZoom() * this.configObj.curConfig.snappingStep
|
||||
|
@ -818,7 +818,7 @@ class Editor extends EditorStartup {
|
|||
* @returns {void}
|
||||
*/
|
||||
rotateSelected (cw, step) {
|
||||
if (isNullish(this.selectedElement) || this.multiselected) { return }
|
||||
if (!this.selectedElement || this.multiselected) { return }
|
||||
if (!cw) { step *= -1 }
|
||||
const angle = Number.parseFloat($id('angle').value) + step
|
||||
this.svgCanvas.setRotationAngle(angle)
|
||||
|
|
|
@ -11,14 +11,6 @@ function toFixedNumeric (value, precision) {
|
|||
if (precision === undefined) precision = 0
|
||||
return Math.round(value * (10 ** precision)) / (10 ** precision)
|
||||
}
|
||||
/**
|
||||
* Whether a value is `null` or `undefined`.
|
||||
* @param {any} val
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isNullish = (val) => {
|
||||
return val === null || val === undefined
|
||||
}
|
||||
/**
|
||||
* Controls for all the input elements for the typing in color values.
|
||||
*/
|
||||
|
@ -39,7 +31,7 @@ export default class ColorValuePicker {
|
|||
* @returns {Event|false|void}
|
||||
*/
|
||||
function keyDown (e) {
|
||||
if (e.target.value === '' && e.target !== hex && ((!isNullish(bindedHex) && e.target !== bindedHex) || isNullish(bindedHex))) return undefined
|
||||
if (e.target.value === '' && e.target !== hex && ((bindedHex && e.target !== bindedHex) || !bindedHex)) return undefined
|
||||
if (!validateKey(e)) return e
|
||||
switch (e.target) {
|
||||
case red:
|
||||
|
@ -137,8 +129,8 @@ export default class ColorValuePicker {
|
|||
*/
|
||||
function keyUp (e) {
|
||||
if (e.target.value === '' && e.target !== hex &&
|
||||
((!isNullish(bindedHex) && e.target !== bindedHex) ||
|
||||
isNullish(bindedHex))) return undefined
|
||||
((bindedHex && e.target !== bindedHex) ||
|
||||
!bindedHex)) return undefined
|
||||
if (!validateKey(e)) return e
|
||||
switch (e.target) {
|
||||
case red:
|
||||
|
@ -181,7 +173,7 @@ export default class ColorValuePicker {
|
|||
break
|
||||
case ahex:
|
||||
ahex.value = ahex.value.replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 2)
|
||||
color.val('a', !isNullish(ahex.value) ? Number.parseInt(ahex.value, 16) : null, e.target)
|
||||
color.val('a', ahex.value ? Number.parseInt(ahex.value, 16) : null, e.target)
|
||||
break
|
||||
}
|
||||
return undefined
|
||||
|
@ -192,7 +184,7 @@ export default class ColorValuePicker {
|
|||
* @returns {void}
|
||||
*/
|
||||
function blur (e) {
|
||||
if (!isNullish(color.value)) {
|
||||
if (color.value) {
|
||||
switch (e.target) {
|
||||
case red:
|
||||
color.value = 'r'
|
||||
|
@ -274,16 +266,16 @@ export default class ColorValuePicker {
|
|||
*/
|
||||
function colorChanged (ui, context) {
|
||||
const all = ui.val('all')
|
||||
if (context !== red) red.value = (!isNullish(all) ? all.r : '')
|
||||
if (context !== green) green.value = (!isNullish(all) ? all.g : '')
|
||||
if (context !== blue) blue.value = (!isNullish(all) ? all.b : '')
|
||||
if (alpha && context !== alpha) alpha.value = (!isNullish(all) ? toFixedNumeric((all.a * 100) / 255, alphaPrecision) : '')
|
||||
if (context !== hue) hue.value = (!isNullish(all) ? all.h : '')
|
||||
if (context !== saturation) saturation.value = (!isNullish(all) ? all.s : '')
|
||||
if (context !== value) value.value = (!isNullish(all) ? all.v : '')
|
||||
if (context !== hex && ((bindedHex && context !== bindedHex) || !bindedHex)) hex.value = (!isNullish(all) ? all.hex : '')
|
||||
if (bindedHex && context !== bindedHex && context !== hex) bindedHex.value = (!isNullish(all) ? all.hex : '')
|
||||
if (ahex && context !== ahex) ahex.value = (!isNullish(all) ? all.ahex.substring(6) : '')
|
||||
if (context !== red) red.value = (all ? all.r : '')
|
||||
if (context !== green) green.value = (all ? all.g : '')
|
||||
if (context !== blue) blue.value = (all ? all.b : '')
|
||||
if (alpha && context !== alpha) alpha.value = (all ? toFixedNumeric((all.a * 100) / 255, alphaPrecision) : '')
|
||||
if (context !== hue) hue.value = (all ? all.h : '')
|
||||
if (context !== saturation) saturation.value = (all ? all.s : '')
|
||||
if (context !== value) value.value = (all ? all.v : '')
|
||||
if (context !== hex && ((bindedHex && context !== bindedHex) || !bindedHex)) hex.value = (all ? all.hex : '')
|
||||
if (bindedHex && context !== bindedHex && context !== hex) bindedHex.value = (all ? all.hex : '')
|
||||
if (ahex && context !== ahex) ahex.value = (all ? all.ahex.substring(6) : '')
|
||||
}
|
||||
/**
|
||||
* Unbind all events and null objects.
|
||||
|
|
|
@ -1337,34 +1337,34 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
|||
</tr>
|
||||
<tr class="Hue">
|
||||
<td class="Radio"><label title="${i18next.t('config.jpicker_tooltip_hue_radio')}"><input type="radio" value="h"${settings.color.mode === 'h' ? ' checked="checked"' : ''}/>H:</label></td>
|
||||
<td class="Text"><input type="text" maxlength="3" value="${!isNullish(all) ? all.h : ''}" title="${i18next.t('config.jpicker_tooltip_hue_textbox')}"/> °</td>
|
||||
<td class="Text"><input type="text" maxlength="3" value="${all ? all.h : ''}" title="${i18next.t('config.jpicker_tooltip_hue_textbox')}"/> °</td>
|
||||
</tr>
|
||||
<tr class="Saturation">
|
||||
<td class="Radio"><label title="${i18next.t('config.jpicker_tooltip_saturation_radio')}"><input type="radio" value="s"${settings.color.mode === 's' ? ' checked="checked"' : ''}/>S:</label></td>
|
||||
<td class="Text"><input type="text" maxlength="3" value="${!isNullish(all) ? all.s : ''}" title="${i18next.t('config.jpicker_tooltip_saturation_textbox')}"/> %</td>
|
||||
<td class="Text"><input type="text" maxlength="3" value="${all ? all.s : ''}" title="${i18next.t('config.jpicker_tooltip_saturation_textbox')}"/> %</td>
|
||||
</tr>
|
||||
<tr class="Value">
|
||||
<td class="Radio"><label title="${i18next.t('config.jpicker_tooltip_value_radio')}"><input type="radio" value="v"${settings.color.mode === 'v' ? ' checked="checked"' : ''}/>V:</label><br/><br/></td>
|
||||
<td class="Text"><input type="text" maxlength="3" value="${!isNullish(all) ? all.v : ''}" title="${i18next.t('config.jpicker_tooltip_value_textbox')}"/> %<br/><br/></td>
|
||||
<td class="Text"><input type="text" maxlength="3" value="${all ? all.v : ''}" title="${i18next.t('config.jpicker_tooltip_value_textbox')}"/> %<br/><br/></td>
|
||||
</tr>
|
||||
<tr class="Red">
|
||||
<td class="Radio"><label title="${i18next.t('config.jpicker_tooltip_red_radio')}"><input type="radio" value="r"${settings.color.mode === 'r' ? ' checked="checked"' : ''}/>R:</label></td>
|
||||
<td class="Text"><input type="text" maxlength="3" value="${!isNullish(all) ? all.r : ''}" title="${i18next.t('config.jpicker_tooltip_red_textbox')}"/></td>
|
||||
<td class="Text"><input type="text" maxlength="3" value="${all ? all.r : ''}" title="${i18next.t('config.jpicker_tooltip_red_textbox')}"/></td>
|
||||
</tr>
|
||||
<tr class="Green">
|
||||
<td class="Radio"><label title="${i18next.t('config.jpicker_tooltip_green_radio')}"><input type="radio" value="g"${settings.color.mode === 'g' ? ' checked="checked"' : ''}/>G:</label></td>
|
||||
<td class="Text"><input type="text" maxlength="3" value="${!isNullish(all) ? all.g : ''}" title="${i18next.t('config.jpicker_tooltip_green_textbox')}"/></td>
|
||||
<td class="Text"><input type="text" maxlength="3" value="${all ? all.g : ''}" title="${i18next.t('config.jpicker_tooltip_green_textbox')}"/></td>
|
||||
</tr>
|
||||
<tr class="Blue">
|
||||
<td class="Radio"><label title="${i18next.t('config.jpicker_tooltip_blue_radio')}"><input type="radio" value="b"${settings.color.mode === 'b' ? ' checked="checked"' : ''}/>B:</label></td>
|
||||
<td class="Text"><input type="text" maxlength="3" value="${!isNullish(all) ? all.b : ''}" title="${i18next.t('config.jpicker_tooltip_blue_textbox')}"/></td>
|
||||
<td class="Text"><input type="text" maxlength="3" value="${all ? all.b : ''}" title="${i18next.t('config.jpicker_tooltip_blue_textbox')}"/></td>
|
||||
</tr>
|
||||
<tr class="Alpha">
|
||||
<td class="Radio">${win.alphaSupport ? `<label title="${i18next.t('config.jpicker_tooltip_alpha_radio')}"><input type="radio" value="a"${settings.color.mode === 'a' ? ' checked="checked"' : ''}/>A:</label>` : ' '}</td>
|
||||
<td class="Text">${win.alphaSupport ? `<input type="text" maxlength="${3 + win.alphaPrecision}" value="${!isNullish(all) ? toFixedNumeric((all.a * 100) / 255, win.alphaPrecision) : ''}" title="${i18next.t('config.jpicker_tooltip_alpha_textbox')}"/> %` : ' '}</td>
|
||||
<td class="Text">${win.alphaSupport ? `<input type="text" maxlength="${3 + win.alphaPrecision}" value="${all ? toFixedNumeric((all.a * 100) / 255, win.alphaPrecision) : ''}" title="${i18next.t('config.jpicker_tooltip_alpha_textbox')}"/> %` : ' '}</td>
|
||||
</tr>
|
||||
<tr class="Hex">
|
||||
<td colspan="2" class="Text"><label title="${i18next.t('config.jpicker_tooltip_hex_textbox')}">#:<input type="text" maxlength="6" class="Hex" value="${!isNullish(all) ? all.hex : ''}"/></label>${win.alphaSupport ? `<input type="text" maxlength="2" class="AHex" value="${!isNullish(all) ? all.ahex.substring(6) : ''}" title="${i18next.t('config.jpicker_tooltip_hex_alpha')}"/></td>` : ' '}
|
||||
<td colspan="2" class="Text"><label title="${i18next.t('config.jpicker_tooltip_hex_textbox')}">#:<input type="text" maxlength="6" class="Hex" value="${all ? all.hex : ''}"/></label>${win.alphaSupport ? `<input type="text" maxlength="2" class="AHex" value="${all ? all.ahex.substring(6) : ''}" title="${i18next.t('config.jpicker_tooltip_hex_alpha')}"/></td>` : ' '}
|
||||
</tr>
|
||||
</tbody></table>`
|
||||
if (win.expandable) {
|
||||
|
@ -1455,7 +1455,7 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
|||
win.expandable && win.bindToInput ? win.input : null,
|
||||
win.alphaPrecision
|
||||
)
|
||||
const hex = !isNullish(all) ? all.hex : null
|
||||
const hex = all ? all.hex : null
|
||||
const preview = tbody.querySelector('#Preview')
|
||||
const button = tbody.querySelector('#Button')
|
||||
activePreview = preview.querySelector('#Active')
|
||||
|
@ -1523,7 +1523,7 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
|||
iconColor.style.backgroundColor = (hex && '#' + hex) || 'transparent'
|
||||
iconAlpha = that.icon.querySelector('.Alpha')
|
||||
setImg.call(that, iconAlpha, images.clientPath + 'bar-opacity.png')
|
||||
setAlpha.call(that, iconAlpha, toFixedNumeric(((255 - (!isNullish(all) ? all.a : 0)) * 100) / 255, 4))
|
||||
setAlpha.call(that, iconAlpha, toFixedNumeric(((255 - (all ? all.a : 0)) * 100) / 255, 4))
|
||||
iconImage = that.icon.querySelector('.Image')
|
||||
iconImage.style.backgroundImage = 'url(\'' + images.clientPath + images.picker.file + '\')'
|
||||
iconImage.addEventListener('click', iconImageClicked)
|
||||
|
@ -1531,7 +1531,7 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
|||
win.input.style.backgroundColor = (hex && '#' + hex) || 'transparent'
|
||||
win.input.style.color = isNullish(all) || all.v > 75 ? '#000000' : '#ffffff'
|
||||
}
|
||||
const moveBar = tbody.querySelector('.Move')
|
||||
moveBar = tbody.querySelector('.Move')
|
||||
moveBar.addEventListener('mousedown', moveBarMouseDown)
|
||||
color.active.bind(expandableColorChanged)
|
||||
} else {
|
||||
|
@ -1658,7 +1658,7 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
|||
let iconColor = null // iconColor for popup icon
|
||||
let iconAlpha = null // iconAlpha for popup icon
|
||||
let iconImage = null // iconImage popup icon
|
||||
const moveBar = null // drag bar
|
||||
let moveBar = null // drag bar
|
||||
Object.assign(that, {
|
||||
// public properties, methods, and callbacks
|
||||
commitCallback, // commitCallback function can be overridden to return the selected color to a method you specify when the user clicks "OK"
|
||||
|
|
|
@ -233,9 +233,7 @@ export default {
|
|||
}
|
||||
// Else fall through
|
||||
default:
|
||||
// TODO: See if there's a way to base64 encode the binary data stream
|
||||
// const str = 'data:;base64,' + svgedit.utilities.encode64(response, true);
|
||||
|
||||
// TODO: See if there's a way to base64 encode the binary data stream
|
||||
// Assume it's raw image data
|
||||
// importImage(str);
|
||||
|
||||
|
|
|
@ -56,11 +56,7 @@ class BottomPanel {
|
|||
break
|
||||
default:
|
||||
{
|
||||
const zoomlevel = Number(value) / 100
|
||||
if (zoomlevel < 0.001) {
|
||||
value = 0.1
|
||||
return
|
||||
}
|
||||
const zoomlevel = Number(value) > 0.1 ? Number(value) > 0.1 : 0.1
|
||||
const zoom = this.editor.svgCanvas.getZoom()
|
||||
const { workarea } = this.editor
|
||||
this.editor.zoomChanged(window, {
|
||||
|
|
|
@ -409,7 +409,7 @@ class TopPanel {
|
|||
'#group'
|
||||
)
|
||||
|
||||
// if (!isNullish(elem))
|
||||
// if (elem)
|
||||
} else if (this.multiselected) {
|
||||
this.displayTool('multiselected_panel')
|
||||
menuItems.setAttribute('enablemenuitems', '#group')
|
||||
|
|
|
@ -24,10 +24,6 @@ const pathMap = [
|
|||
* @function module:coords.EditorContext#getGridSnapping
|
||||
* @returns {boolean}
|
||||
*/
|
||||
/**
|
||||
* @function module:coords.EditorContext#getDrawing
|
||||
* @returns {module:draw.Drawing}
|
||||
*/
|
||||
/**
|
||||
* @function module:coords.EditorContext#getSvgRoot
|
||||
* @returns {SVGSVGElement}
|
||||
|
@ -84,7 +80,7 @@ export const remapElement = function (selected, changes, m) {
|
|||
newgrad.setAttribute('y1', -(y1 - 1))
|
||||
newgrad.setAttribute('y2', -(y2 - 1))
|
||||
}
|
||||
newgrad.id = svgCanvas.getDrawing().getNextId()
|
||||
newgrad.id = svgCanvas.getCurrentDrawing().getNextId()
|
||||
findDefs().append(newgrad)
|
||||
selected.setAttribute(type, 'url(#' + newgrad.id + ')')
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ const dataStorage = {
|
|||
},
|
||||
remove: function (element, key) {
|
||||
const ret = this._storage.get(element).delete(key)
|
||||
if (!this._storage.get(element).size === 0) {
|
||||
if (this._storage.get(element).size === 0) {
|
||||
this._storage.delete(element)
|
||||
}
|
||||
return ret
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* @copyright 2010 Jeff Schiller
|
||||
*/
|
||||
|
||||
import { getHref, setHref, getRotationAngle, isNullish, getBBox } from './utilities.js'
|
||||
import { getHref, setHref, getRotationAngle, getBBox } from './utilities.js'
|
||||
|
||||
/**
|
||||
* Group: Undo/Redo history management.
|
||||
|
@ -255,7 +255,7 @@ export class RemoveElementCommand extends Command {
|
|||
*/
|
||||
unapply (handler) {
|
||||
super.unapply(handler, () => {
|
||||
if (isNullish(this.nextSibling) && window.console) {
|
||||
if (!this.nextSibling && window.console) {
|
||||
console.error('Reference element was lost')
|
||||
}
|
||||
this.parent.insertBefore(this.elem, this.nextSibling) // Don't use `before` or `prepend` as `this.nextSibling` may be `null`
|
||||
|
@ -581,7 +581,7 @@ export class UndoManager {
|
|||
const oldValues = new Array(i); const elements = new Array(i)
|
||||
while (i--) {
|
||||
const elem = elems[i]
|
||||
if (isNullish(elem)) { continue }
|
||||
if (!elem) { continue }
|
||||
elements[i] = elem
|
||||
oldValues[i] = elem.getAttribute(attrName)
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ export class UndoManager {
|
|||
let i = changeset.elements.length
|
||||
while (i--) {
|
||||
const elem = changeset.elements[i]
|
||||
if (isNullish(elem)) { continue }
|
||||
if (!elem) { continue }
|
||||
const changes = {}
|
||||
changes[attrName] = changeset.oldValues[i]
|
||||
if (changes[attrName] !== elem.getAttribute(attrName)) {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { NS } from './namespaces.js'
|
||||
import { toXml, walkTree, isNullish } from './utilities.js'
|
||||
import { toXml, walkTree } from './utilities.js'
|
||||
|
||||
/**
|
||||
* This class encapsulates the concept of a layer in the drawing. It can be constructed with
|
||||
|
@ -114,7 +114,7 @@ class Layer {
|
|||
*/
|
||||
getOpacity () {
|
||||
const opacity = this.group_.getAttribute('opacity')
|
||||
if (isNullish(opacity)) {
|
||||
if (!opacity) {
|
||||
return 1
|
||||
}
|
||||
return Number.parseFloat(opacity)
|
||||
|
@ -218,7 +218,7 @@ Layer.CLASS_REGEX = new RegExp('(\\s|^)' + Layer.CLASS_NAME + '(\\s|$)')
|
|||
*/
|
||||
function addLayerClass (elem) {
|
||||
const classes = elem.getAttribute('class')
|
||||
if (isNullish(classes) || !classes.length) {
|
||||
if (!classes || !classes.length) {
|
||||
elem.setAttribute('class', Layer.CLASS_NAME)
|
||||
} else if (!Layer.CLASS_REGEX.test(classes)) {
|
||||
elem.setAttribute('class', classes + ' ' + Layer.CLASS_NAME)
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
transformListToTransform
|
||||
} from './math.js'
|
||||
import {
|
||||
assignAttributes, getElement, getRotationAngle, snapToGrid, isNullish,
|
||||
assignAttributes, getElement, getRotationAngle, snapToGrid,
|
||||
getBBox
|
||||
} from './utilities.js'
|
||||
|
||||
|
@ -541,7 +541,7 @@ export const pathActionsMethod = (function () {
|
|||
// Start selection box
|
||||
if (!path.dragging) {
|
||||
let rubberBox = svgCanvas.getRubberBox()
|
||||
if (isNullish(rubberBox)) {
|
||||
if (!rubberBox) {
|
||||
rubberBox = svgCanvas.setRubberBox(
|
||||
svgCanvas.selectorManager.getRubberBandBox()
|
||||
)
|
||||
|
@ -875,7 +875,7 @@ export const pathActionsMethod = (function () {
|
|||
* @returns {false|void}
|
||||
*/
|
||||
resetOrientation (pth) {
|
||||
if (isNullish(pth) || pth.nodeName !== 'path') { return false }
|
||||
if (pth?.nodeName !== 'path') { return false }
|
||||
const tlist = pth.transform.baseVal
|
||||
const m = transformListToTransform(tlist).matrix
|
||||
tlist.clear()
|
||||
|
@ -1007,7 +1007,7 @@ export const pathActionsMethod = (function () {
|
|||
return true
|
||||
})
|
||||
|
||||
if (isNullish(openPt)) {
|
||||
if (!openPt) {
|
||||
// Single path, so close last seg
|
||||
openPt = path.segs.length - 1
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
transformPoint, getMatrix
|
||||
} from './math.js'
|
||||
import {
|
||||
assignAttributes, getRotationAngle, isNullish,
|
||||
assignAttributes, getRotationAngle,
|
||||
getElement
|
||||
} from './utilities.js'
|
||||
|
||||
|
@ -635,7 +635,7 @@ export class Path {
|
|||
seg.next.prev = seg
|
||||
seg.mate = segs[startI]
|
||||
seg.addGrip()
|
||||
if (isNullish(this.first_seg)) {
|
||||
if (!this.first_seg) {
|
||||
this.first_seg = seg
|
||||
}
|
||||
} else if (!nextSeg) {
|
||||
|
@ -907,7 +907,7 @@ export class Path {
|
|||
*/
|
||||
selectPt (pt, ctrlNum) {
|
||||
this.clearSelection()
|
||||
if (isNullish(pt)) {
|
||||
if (!pt) {
|
||||
this.eachSeg(function (i) {
|
||||
// 'this' is the segment here.
|
||||
if (this.prev) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import { shortFloat } from '../common/units.js'
|
|||
import { transformPoint } from './math.js'
|
||||
import {
|
||||
getRotationAngle, getBBox,
|
||||
getRefElem, findDefs, isNullish,
|
||||
getRefElem, findDefs,
|
||||
getBBox as utilsGetBBox
|
||||
} from './utilities.js'
|
||||
import {
|
||||
|
@ -209,10 +209,6 @@ export let path = null
|
|||
* @param {string} cm The mode
|
||||
* @returns {string} The same mode as passed in
|
||||
*/
|
||||
/**
|
||||
* @function module:path.EditorContext#getDrawnPath
|
||||
* @returns {SVGPathElement|null}
|
||||
*/
|
||||
/**
|
||||
* @function module:path.EditorContext#setDrawnPath
|
||||
* @param {SVGPathElement|null} dp
|
||||
|
@ -501,7 +497,7 @@ export const recalcRotatedPath = () => {
|
|||
|
||||
const rvals = getRotVals(seg.x, seg.y)
|
||||
const points = [rvals.x, rvals.y]
|
||||
if (!isNullish(seg.x1) && !isNullish(seg.x2)) {
|
||||
if (seg.x1 && seg.x2) {
|
||||
const cVals1 = getRotVals(seg.x1, seg.y1)
|
||||
const cVals2 = getRotVals(seg.x2, seg.y2)
|
||||
points.splice(points.length, 0, cVals1.x, cVals1.y, cVals2.x, cVals2.y)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { NS } from './namespaces.js'
|
||||
import { convertToNum } from '../common/units.js'
|
||||
import { getRotationAngle, getHref, getBBox, getRefElem, isNullish } from './utilities.js'
|
||||
import { getRotationAngle, getHref, getBBox, getRefElem } from './utilities.js'
|
||||
import { BatchCommand, ChangeElementCommand } from './history.js'
|
||||
import { remapElement } from './coords.js'
|
||||
import {
|
||||
|
@ -231,7 +231,7 @@ export const recalculateDimensions = function (selected) {
|
|||
|
||||
// if we haven't created an initial array in polygon/polyline/path, then
|
||||
// make a copy of initial values and include the transform
|
||||
if (isNullish(initial)) {
|
||||
if (!initial) {
|
||||
initial = mergeDeep({}, changes)
|
||||
for (const [attr, val] of Object.entries(initial)) {
|
||||
initial[attr] = convertToNum(attr, val)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { isTouch, isWebkit } from '../common/browser.js' // , isOpera
|
||||
import { getRotationAngle, getBBox, getStrokedBBox, isNullish } from './utilities.js'
|
||||
import { getRotationAngle, getBBox, getStrokedBBox } from './utilities.js'
|
||||
import { transformListToTransform, transformBox, transformPoint } from './math.js'
|
||||
|
||||
let svgCanvas
|
||||
|
@ -439,7 +439,7 @@ export class SelectorManager {
|
|||
* @returns {void}
|
||||
*/
|
||||
releaseSelector (elem) {
|
||||
if (isNullish(elem)) { return }
|
||||
if (!elem) { return }
|
||||
const N = this.selectors.length
|
||||
const sel = this.selectorMap[elem.id]
|
||||
if (sel && !sel.locked) {
|
||||
|
|
Loading…
Reference in New Issue