Formatting.
This commit is contained in:
parent
60841d1b1f
commit
7524bfd256
|
@ -1,38 +1,42 @@
|
|||
<script>
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { createEventDispatcher } from "svelte"
|
||||
import Colorpicker from "@budibase/colorpicker"
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
export let value
|
||||
|
||||
const WAIT = 150;
|
||||
|
||||
|
||||
const WAIT = 150
|
||||
|
||||
function throttle(callback, wait, immediate = false) {
|
||||
let timeout = null
|
||||
let timeout = null
|
||||
let initialCall = true
|
||||
|
||||
|
||||
return function() {
|
||||
const callNow = immediate && initialCall
|
||||
const next = () => {
|
||||
callback.apply(this, arguments)
|
||||
timeout = null
|
||||
}
|
||||
|
||||
if (callNow) {
|
||||
|
||||
if (callNow) {
|
||||
initialCall = false
|
||||
next()
|
||||
}
|
||||
|
||||
|
||||
if (!timeout) {
|
||||
timeout = setTimeout(next, wait)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onChange = throttle(e => {
|
||||
dispatch('change', e.detail)
|
||||
}, WAIT, true)
|
||||
|
||||
const onChange = throttle(
|
||||
e => {
|
||||
dispatch("change", e.detail)
|
||||
},
|
||||
WAIT,
|
||||
true
|
||||
)
|
||||
</script>
|
||||
|
||||
<Colorpicker value={value || '#C4C4C4'} on:change={onChange} />
|
||||
|
|
Loading…
Reference in New Issue