mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-14 00:54:48 +08:00
Small refactoring
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
.ueb-draggable,
|
||||
.ueb-node {
|
||||
.ueb-draggable {
|
||||
/* Indicate the element draggable */
|
||||
cursor: move;
|
||||
/* It will be positioned absolutely */
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
--ueb-node-radius: 7px;
|
||||
}
|
||||
|
||||
u-blueprint {
|
||||
ueb-blueprint {
|
||||
display: block;
|
||||
position: relative;
|
||||
font-family: Roboto, Noto, Oxygen, Ubuntu, "Open Sans", "Helvetica Neue",
|
||||
@@ -58,7 +58,7 @@ u-blueprint {
|
||||
scrollbar-width: 0;
|
||||
}
|
||||
|
||||
u-blueprint[data-focused="true"] .ueb-viewport-body {
|
||||
ueb-blueprint[data-focused="true"] .ueb-viewport-body {
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ u-blueprint[data-focused="true"] .ueb-viewport-body {
|
||||
translateY(calc(var(--ueb-translate-y) * 1px));
|
||||
}
|
||||
|
||||
.ueb-node {
|
||||
ueb-node {
|
||||
display: block;
|
||||
position: absolute;
|
||||
transform: translateX(calc(var(--ueb-position-x) * 1px))
|
||||
@@ -285,9 +285,12 @@ u-blueprint[data-focused="true"] .ueb-viewport-body {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
u-pin {
|
||||
ueb-pin {
|
||||
display: block;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
ueb-selector[data-selecting="false"] ~ ueb-node ueb-pin {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
32
dist/ueblueprint.js
vendored
32
dist/ueblueprint.js
vendored
@@ -105,13 +105,6 @@ class OrderedIndexArray {
|
||||
|| comparisonValue != null && position == this.currentPosition && this.comparisonValueSupplier(element) < comparisonValue) {
|
||||
++this.currentPosition;
|
||||
}
|
||||
/*
|
||||
let newArray = new Uint32Array(this.array.length + 1)
|
||||
newArray.set(this.array.subarray(0, position), 0)
|
||||
newArray[position] = element
|
||||
newArray.set(this.array.subarray(position), position + 1)
|
||||
this.array = newArray
|
||||
*/
|
||||
this.shiftRight(position);
|
||||
this.array[position] = element;
|
||||
++this.length;
|
||||
@@ -137,12 +130,6 @@ class OrderedIndexArray {
|
||||
if (position < this.currentPosition) {
|
||||
--this.currentPosition;
|
||||
}
|
||||
/*
|
||||
let newArray = new Uint32Array(this.array.length - 1)
|
||||
newArray.set(this.array.subarray(0, position), 0)
|
||||
newArray.set(this.array.subarray(position + 1), position)
|
||||
this.array = newArray
|
||||
*/
|
||||
this.shiftLeft(position);
|
||||
--this.length;
|
||||
return position
|
||||
@@ -367,7 +354,7 @@ class GraphElement extends HTMLElement {
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
this.blueprint = this.closest("u-blueprint");
|
||||
this.blueprint = this.closest("ueb-blueprint");
|
||||
this.template.apply(this);
|
||||
}
|
||||
}
|
||||
@@ -454,7 +441,7 @@ class GraphSelector extends GraphElement {
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("u-selector", GraphSelector);
|
||||
customElements.define("ueb-selector", GraphSelector);
|
||||
|
||||
/** @typedef {import("../Blueprint").default} Blueprint */
|
||||
class BlueprintTemplate extends Template {
|
||||
@@ -704,8 +691,8 @@ class Pointing extends Context {
|
||||
const scaleCorrection = 1 / Utility.getScale(this.target);
|
||||
const targetOffset = this.movementSpace.getBoundingClientRect();
|
||||
let location = [
|
||||
(mouseEvent.clientX - targetOffset.x) * scaleCorrection,
|
||||
(mouseEvent.clientY - targetOffset.y) * scaleCorrection
|
||||
Math.round((mouseEvent.clientX - targetOffset.x) * scaleCorrection),
|
||||
Math.round((mouseEvent.clientY - targetOffset.y) * scaleCorrection)
|
||||
];
|
||||
return location
|
||||
}
|
||||
@@ -1133,7 +1120,7 @@ class GraphPin extends GraphElement {
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("u-pin", GraphPin);
|
||||
customElements.define("ueb-pin", GraphPin);
|
||||
|
||||
/**
|
||||
* @typedef {import("../graph/GraphNode").default} GraphNode
|
||||
@@ -1193,7 +1180,6 @@ class NodeTemplate extends SelectableDraggableTemplate {
|
||||
*/
|
||||
apply(node) {
|
||||
super.apply(node);
|
||||
node.classList.add("ueb-node");
|
||||
if (node.selected) {
|
||||
node.classList.add("ueb-selected");
|
||||
}
|
||||
@@ -1485,7 +1471,7 @@ class GraphNode extends SelectableDraggable {
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("u-node", GraphNode);
|
||||
customElements.define("ueb-node", GraphNode);
|
||||
|
||||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
||||
|
||||
@@ -1888,7 +1874,7 @@ class Unfocus extends Context {
|
||||
*/
|
||||
clickedSomewhere(e) {
|
||||
// If target is inside the blueprint grid
|
||||
if (e.target.closest("u-blueprint")) {
|
||||
if (e.target.closest("ueb-blueprint")) {
|
||||
return
|
||||
}
|
||||
this.blueprint.setFocused(false);
|
||||
@@ -2297,7 +2283,7 @@ class Blueprint extends GraphElement {
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("u-blueprint", Blueprint);
|
||||
customElements.define("ueb-blueprint", Blueprint);
|
||||
|
||||
/**
|
||||
* @typedef {import("../graph/GraphLink").default} GraphLink
|
||||
@@ -2336,7 +2322,7 @@ class GraphLink extends GraphElement {
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("u-link", GraphLink);
|
||||
customElements.define("ueb-link", GraphLink);
|
||||
|
||||
class GeneralSerializer extends Serializer {
|
||||
|
||||
|
||||
@@ -330,4 +330,4 @@ export default class Blueprint extends GraphElement {
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("u-blueprint", Blueprint)
|
||||
customElements.define("ueb-blueprint", Blueprint)
|
||||
|
||||
@@ -15,7 +15,7 @@ export default class GraphElement extends HTMLElement {
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
this.blueprint = this.closest("u-blueprint")
|
||||
this.blueprint = this.closest("ueb-blueprint")
|
||||
this.template.apply(this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@ export default class GraphLink extends GraphElement {
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("u-link", GraphLink)
|
||||
customElements.define("ueb-link", GraphLink)
|
||||
|
||||
@@ -56,4 +56,4 @@ export default class GraphNode extends SelectableDraggable {
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("u-node", GraphNode)
|
||||
customElements.define("ueb-node", GraphNode)
|
||||
|
||||
@@ -42,4 +42,4 @@ export default class GraphPin extends GraphElement {
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("u-pin", GraphPin)
|
||||
customElements.define("ueb-pin", GraphPin)
|
||||
|
||||
@@ -37,4 +37,4 @@ export default class GraphSelector extends GraphElement {
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("u-selector", GraphSelector)
|
||||
customElements.define("ueb-selector", GraphSelector)
|
||||
|
||||
@@ -17,8 +17,8 @@ export default class Pointing extends Context {
|
||||
const scaleCorrection = 1 / Utility.getScale(this.target)
|
||||
const targetOffset = this.movementSpace.getBoundingClientRect()
|
||||
let location = [
|
||||
(mouseEvent.clientX - targetOffset.x) * scaleCorrection,
|
||||
(mouseEvent.clientY - targetOffset.y) * scaleCorrection
|
||||
Math.round((mouseEvent.clientX - targetOffset.x) * scaleCorrection),
|
||||
Math.round((mouseEvent.clientY - targetOffset.y) * scaleCorrection)
|
||||
]
|
||||
return location
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export default class Unfocus extends Context {
|
||||
*/
|
||||
clickedSomewhere(e) {
|
||||
// If target is inside the blueprint grid
|
||||
if (e.target.closest("u-blueprint")) {
|
||||
if (e.target.closest("ueb-blueprint")) {
|
||||
return
|
||||
}
|
||||
this.blueprint.setFocused(false)
|
||||
|
||||
@@ -70,13 +70,6 @@ export default class OrderedIndexArray {
|
||||
|| comparisonValue != null && position == this.currentPosition && this.comparisonValueSupplier(element) < comparisonValue) {
|
||||
++this.currentPosition
|
||||
}
|
||||
/*
|
||||
let newArray = new Uint32Array(this.array.length + 1)
|
||||
newArray.set(this.array.subarray(0, position), 0)
|
||||
newArray[position] = element
|
||||
newArray.set(this.array.subarray(position), position + 1)
|
||||
this.array = newArray
|
||||
*/
|
||||
this.shiftRight(position)
|
||||
this.array[position] = element
|
||||
++this.length
|
||||
@@ -102,12 +95,6 @@ export default class OrderedIndexArray {
|
||||
if (position < this.currentPosition) {
|
||||
--this.currentPosition
|
||||
}
|
||||
/*
|
||||
let newArray = new Uint32Array(this.array.length - 1)
|
||||
newArray.set(this.array.subarray(0, position), 0)
|
||||
newArray.set(this.array.subarray(position + 1), position)
|
||||
this.array = newArray
|
||||
*/
|
||||
this.shiftLeft(position)
|
||||
--this.length
|
||||
return position
|
||||
|
||||
@@ -61,7 +61,6 @@ export default class NodeTemplate extends SelectableDraggableTemplate {
|
||||
*/
|
||||
apply(node) {
|
||||
super.apply(node)
|
||||
node.classList.add("ueb-node")
|
||||
if (node.selected) {
|
||||
node.classList.add("ueb-selected")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user