mirror of https://github.com/Budibase/budibase.git
5 changed files with 41 additions and 67 deletions
@ -1,42 +1,8 @@ |
|||||
<script> |
<script> |
||||
import { createEventDispatcher } from "svelte" |
import { ColorPicker } from "@budibase/bbui" |
||||
import Colorpicker from "@budibase/colorpicker" |
import { store } from "builderStore" |
||||
|
|
||||
const dispatch = createEventDispatcher() |
|
||||
|
|
||||
export let value |
export let value |
||||
|
|
||||
const WAIT = 150 |
|
||||
|
|
||||
function throttle(callback, wait, immediate = false) { |
|
||||
let timeout = null |
|
||||
let initialCall = true |
|
||||
|
|
||||
return function () { |
|
||||
const callNow = immediate && initialCall |
|
||||
const next = () => { |
|
||||
callback.apply(this, arguments) |
|
||||
timeout = null |
|
||||
} |
|
||||
|
|
||||
if (callNow) { |
|
||||
initialCall = false |
|
||||
next() |
|
||||
} |
|
||||
|
|
||||
if (!timeout) { |
|
||||
timeout = setTimeout(next, wait) |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
const onChange = throttle( |
|
||||
e => { |
|
||||
dispatch("change", e.detail) |
|
||||
}, |
|
||||
WAIT, |
|
||||
true |
|
||||
) |
|
||||
</script> |
</script> |
||||
|
|
||||
<Colorpicker value={value || "#C4C4C4"} on:change={onChange} /> |
<ColorPicker {value} on:change spectrumTheme={$store.theme} /> |
||||
|
|||||
Loading…
Reference in new issue