Debounce hiding binding values to enable interacting with them
This commit is contained in:
parent
14b2bfa8d6
commit
433c3a6306
|
@ -101,6 +101,8 @@
|
||||||
role="presentation"
|
role="presentation"
|
||||||
style="height: {customHeight}; --customZindex: {customZindex};"
|
style="height: {customHeight}; --customZindex: {customZindex};"
|
||||||
transition:fly|local={{ y: -20, duration: animate ? 200 : 0 }}
|
transition:fly|local={{ y: -20, duration: animate ? 200 : 0 }}
|
||||||
|
on:mouseenter
|
||||||
|
on:mouseleave
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
let hoverTarget
|
let hoverTarget
|
||||||
let helpers = handlebarsCompletions()
|
let helpers = handlebarsCompletions()
|
||||||
let selectedCategory
|
let selectedCategory
|
||||||
|
let hideTimeout
|
||||||
|
|
||||||
$: bindingIcons = bindings?.reduce((acc, ele) => {
|
$: bindingIcons = bindings?.reduce((acc, ele) => {
|
||||||
if (ele.icon) {
|
if (ele.icon) {
|
||||||
|
@ -86,6 +87,37 @@
|
||||||
nullColor: "#c678dd",
|
nullColor: "#c678dd",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const showPopover = (target, binding) => {
|
||||||
|
if (hideTimeout) {
|
||||||
|
clearTimeout(hideTimeout)
|
||||||
|
hideTimeout = null
|
||||||
|
}
|
||||||
|
let val = getBindingValue(binding)
|
||||||
|
if (val !== "") {
|
||||||
|
popoverAnchor = target
|
||||||
|
hoverTarget = {
|
||||||
|
code: val,
|
||||||
|
}
|
||||||
|
popover.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const hidePopover = () => {
|
||||||
|
hideTimeout = setTimeout(() => {
|
||||||
|
popover.hide()
|
||||||
|
popoverAnchor = null
|
||||||
|
hoverTarget = null
|
||||||
|
hideTimeout = null
|
||||||
|
}, 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
const stopHiding = () => {
|
||||||
|
if (hideTimeout) {
|
||||||
|
clearTimeout(hideTimeout)
|
||||||
|
hideTimeout = null
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Popover
|
<Popover
|
||||||
|
@ -95,6 +127,8 @@
|
||||||
maxWidth={600}
|
maxWidth={600}
|
||||||
maxHeight={300}
|
maxHeight={300}
|
||||||
dismissible={false}
|
dismissible={false}
|
||||||
|
on:mouseenter={stopHiding}
|
||||||
|
on:mouseleave={hidePopover}
|
||||||
>
|
>
|
||||||
<div class="helper">
|
<div class="helper">
|
||||||
<Layout gap="S">
|
<Layout gap="S">
|
||||||
|
@ -175,21 +209,8 @@
|
||||||
{#each category.bindings as binding}
|
{#each category.bindings as binding}
|
||||||
<li
|
<li
|
||||||
class="binding"
|
class="binding"
|
||||||
on:mouseenter={e => {
|
on:mouseenter={e => showPopover(e.target, binding)}
|
||||||
let val = getBindingValue(binding)
|
on:mouseleave={hidePopover}
|
||||||
if (val !== "") {
|
|
||||||
popoverAnchor = e.target
|
|
||||||
hoverTarget = {
|
|
||||||
code: val,
|
|
||||||
}
|
|
||||||
popover.show()
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
on:mouseleave={() => {
|
|
||||||
popover.hide()
|
|
||||||
popoverAnchor = null
|
|
||||||
hoverTarget = null
|
|
||||||
}}
|
|
||||||
on:focus={() => {}}
|
on:focus={() => {}}
|
||||||
on:blur={() => {}}
|
on:blur={() => {}}
|
||||||
on:click={() => addBinding(binding)}
|
on:click={() => addBinding(binding)}
|
||||||
|
|
Loading…
Reference in New Issue