mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-27 18:54:44 +08:00
Various fixes, smaller refactoring
This commit is contained in:
@@ -90,7 +90,11 @@ export default class LinkTemplate extends IFromToPositionedTemplate {
|
||||
this.blueprint,
|
||||
undefined,
|
||||
/** @param {[Number, Number]} location */
|
||||
location => this.#createKnot(location)
|
||||
location => {
|
||||
location[0] += Configuration.knotOffset[0]
|
||||
location[1] += Configuration.knotOffset[1]
|
||||
this.#createKnot(location)
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export default class IInputPinTemplate extends PinTemplate {
|
||||
|
||||
/** @param {HTMLElement} inputElement*/
|
||||
#updateWrapClass(inputElement) {
|
||||
const width = inputElement.getBoundingClientRect().width + this.nameWidth
|
||||
const width = this.blueprint.scaleCorrect(inputElement.getBoundingClientRect().width) + this.nameWidth
|
||||
const inputWrapped = this.element.classList.contains("ueb-pin-input-wrap")
|
||||
if (!inputWrapped && width > Configuration.pinInputWrapWidth) {
|
||||
this.element.classList.add("ueb-pin-input-wrap")
|
||||
@@ -55,7 +55,9 @@ export default class IInputPinTemplate extends PinTemplate {
|
||||
super.firstUpdated(changedProperties)
|
||||
this.#inputContentElements = /** @type {HTMLElement[]} */([...this.element.querySelectorAll("ueb-input")])
|
||||
if (/** @type {typeof IInputPinTemplate} */(this.constructor).canWrapInput) {
|
||||
this.nameWidth = this.element.querySelector(".ueb-pin-name").getBoundingClientRect().width
|
||||
this.nameWidth = this.blueprint.scaleCorrect(
|
||||
this.element.querySelector(".ueb-pin-name").getBoundingClientRect().width
|
||||
)
|
||||
this.inputContentElements.forEach(inputElement => this.#updateWrapClass(inputElement))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,12 @@ export default class PinTemplate extends ITemplate {
|
||||
return this.#iconElement
|
||||
}
|
||||
|
||||
/** @type {HTMLElement} */
|
||||
#wrapperElement
|
||||
get wrapperElement() {
|
||||
return this.#wrapperElement
|
||||
}
|
||||
|
||||
isNameRendered = true
|
||||
|
||||
setup() {
|
||||
@@ -47,8 +53,9 @@ export default class PinTemplate extends ITemplate {
|
||||
/** @returns {IInput[]} */
|
||||
createInputObjects() {
|
||||
return [
|
||||
new MouseCreateLink(this.getClickableElement(), this.blueprint, {
|
||||
new MouseCreateLink(this.element, this.blueprint, {
|
||||
moveEverywhere: true,
|
||||
draggableElement: this.#wrapperElement,
|
||||
})
|
||||
]
|
||||
}
|
||||
@@ -106,6 +113,7 @@ export default class PinTemplate extends ITemplate {
|
||||
super.firstUpdated(changedProperties)
|
||||
this.element.style.setProperty("--ueb-pin-color-rgb", this.element.entity.pinColor().cssText)
|
||||
this.#iconElement = this.element.querySelector(".ueb-pin-icon svg") ?? this.element
|
||||
this.#wrapperElement = this.element.querySelector(".ueb-pin-wrapper")
|
||||
}
|
||||
|
||||
getLinkLocation() {
|
||||
@@ -116,6 +124,6 @@ export default class PinTemplate extends ITemplate {
|
||||
}
|
||||
|
||||
getClickableElement() {
|
||||
return this.element
|
||||
return this.#wrapperElement ?? this.element
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user