feat: add options for autoresize

* add `throttle: number` to specify throttle delay (#419 #562)
* add `onResize: () => void` to specify a resize callback (#714)
This commit is contained in:
Justineo
2023-06-13 20:35:45 +08:00
parent 47f7885f19
commit e8697382a1
8 changed files with 99 additions and 56 deletions

View File

@ -4,21 +4,20 @@ import {
computed,
watchEffect,
type Ref,
type InjectionKey
type InjectionKey,
type PropType
} from "vue-demi";
import { EChartsType } from "../types";
import type { EChartsType, LoadingOptions } from "../types";
export const LOADING_OPTIONS_KEY =
"ecLoadingOptions" as unknown as InjectionKey<
UnknownRecord | Ref<UnknownRecord>
LoadingOptions | Ref<LoadingOptions>
>;
type UnknownRecord = Record<string, unknown>;
export function useLoading(
chart: Ref<EChartsType | undefined>,
loading: Ref<boolean>,
loadingOptions: Ref<UnknownRecord | undefined>
loadingOptions: Ref<LoadingOptions | undefined>
): void {
const defaultLoadingOptions = inject(LOADING_OPTIONS_KEY, {});
const realLoadingOptions = computed(() => ({
@ -42,5 +41,5 @@ export function useLoading(
export const loadingProps = {
loading: Boolean,
loadingOptions: Object
loadingOptions: Object as PropType<LoadingOptions>
};