Multiple performance improvements to component selection and hovering
This commit is contained in:
parent
c58ac5810e
commit
5acfc3143d
|
@ -7,12 +7,25 @@ export const INITIAL_HOVER_STATE = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HoverStore extends BudiStore {
|
export class HoverStore extends BudiStore {
|
||||||
|
hoverTimeout
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super({ ...INITIAL_HOVER_STATE })
|
super({ ...INITIAL_HOVER_STATE })
|
||||||
this.hover = this.hover.bind(this)
|
this.hover = this.hover.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
hover(componentId, notifyClient = true) {
|
hover(componentId, notifyClient = true) {
|
||||||
|
clearTimeout(this.hoverTimeout)
|
||||||
|
if (componentId) {
|
||||||
|
this.processHover(componentId, notifyClient)
|
||||||
|
} else {
|
||||||
|
this.hoverTimeout = setTimeout(() => {
|
||||||
|
this.processHover(componentId, notifyClient)
|
||||||
|
}, 10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processHover(componentId, notifyClient) {
|
||||||
if (componentId === get(this.store).componentId) {
|
if (componentId === get(this.store).componentId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<script>
|
<script>
|
||||||
import { onMount, onDestroy } from "svelte"
|
import { onMount, onDestroy } from "svelte"
|
||||||
import IndicatorSet from "./IndicatorSet.svelte"
|
import IndicatorSet from "./IndicatorSet.svelte"
|
||||||
import { builderStore, dndIsDragging, hoverStore } from "stores"
|
import { dndIsDragging, hoverStore } from "stores"
|
||||||
|
|
||||||
$: componentId = $hoverStore.hoveredComponentId
|
$: componentId = $hoverStore.hoveredComponentId
|
||||||
$: zIndex = componentId === $builderStore.selectedComponentId ? 900 : 920
|
|
||||||
|
|
||||||
const onMouseOver = e => {
|
const onMouseOver = e => {
|
||||||
// Ignore if dragging
|
// Ignore if dragging
|
||||||
|
@ -46,6 +45,6 @@
|
||||||
componentId={$dndIsDragging ? null : componentId}
|
componentId={$dndIsDragging ? null : componentId}
|
||||||
color="var(--spectrum-global-color-static-blue-200)"
|
color="var(--spectrum-global-color-static-blue-200)"
|
||||||
transition
|
transition
|
||||||
{zIndex}
|
zIndex="890"
|
||||||
allowResizeAnchors
|
allowResizeAnchors
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
in:fade={{
|
transition:fade|local={{
|
||||||
delay: transition ? 100 : 0,
|
delay: transition ? 100 : 0,
|
||||||
duration: transition ? 100 : 0,
|
duration: transition ? 100 : 0,
|
||||||
}}
|
}}
|
||||||
|
@ -127,10 +127,6 @@
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Icon styles */
|
|
||||||
.label :global(.spectrum-Icon + .text) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Anchor */
|
/* Anchor */
|
||||||
.anchor {
|
.anchor {
|
||||||
--size: 24px;
|
--size: 24px;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
$: visibleIndicators = indicators.filter(x => x.visible)
|
$: visibleIndicators = indicators.filter(x => x.visible)
|
||||||
$: offset = $builderStore.inBuilder ? 0 : 2
|
$: offset = $builderStore.inBuilder ? 0 : 2
|
||||||
|
$: componentId, debouncedUpdate()
|
||||||
|
|
||||||
let updating = false
|
let updating = false
|
||||||
let observers = []
|
let observers = []
|
||||||
|
|
|
@ -98,7 +98,7 @@ const loadBudibase = async () => {
|
||||||
context: stringifiedContext,
|
context: stringifiedContext,
|
||||||
})
|
})
|
||||||
} else if (type === "hover-component") {
|
} else if (type === "hover-component") {
|
||||||
hoverStore.actions.hoverComponent(data)
|
hoverStore.actions.hoverComponent(data, false)
|
||||||
} else if (type === "builder-meta") {
|
} else if (type === "builder-meta") {
|
||||||
builderStore.actions.setMetadata(data)
|
builderStore.actions.setMetadata(data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,27 @@ const createHoverStore = () => {
|
||||||
const store = writable({
|
const store = writable({
|
||||||
hoveredComponentId: null,
|
hoveredComponentId: null,
|
||||||
})
|
})
|
||||||
|
let hoverTimeout
|
||||||
|
|
||||||
const hoverComponent = id => {
|
const hoverComponent = (id, notifyBuilder = true) => {
|
||||||
|
clearTimeout(hoverTimeout)
|
||||||
|
if (id) {
|
||||||
|
processHover(id, notifyBuilder)
|
||||||
|
} else {
|
||||||
|
hoverTimeout = setTimeout(() => {
|
||||||
|
processHover(id, notifyBuilder)
|
||||||
|
}, 10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const processHover = (id, notifyBuilder = true) => {
|
||||||
if (id === get(store).hoveredComponentId) {
|
if (id === get(store).hoveredComponentId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
store.set({ hoveredComponentId: id })
|
store.set({ hoveredComponentId: id })
|
||||||
eventStore.actions.dispatchEvent("hover-component", { id })
|
if (notifyBuilder) {
|
||||||
|
eventStore.actions.dispatchEvent("hover-component", { id })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue