useProjection
Category
Export Size
278 B
Package
@vueuse/math
Last Changed
5 months ago
Related
Reactive numeric projection from one domain to another.
Demo
Projection from [0, 10] to [10, 100]
Input: 0
Output: 10
Usage
ts
import { useProjection } from '@vueuse/math'
const input = ref(0)
const projected = useProjection(input, [0, 10], [0, 100])
input.value = 5 // projected.value === 50
input.value = 10 // projected.value === 100
import { useProjection } from '@vueuse/math'
const input = ref(0)
const projected = useProjection(input, [0, 10], [0, 100])
input.value = 5 // projected.value === 50
input.value = 10 // projected.value === 100
Type Declarations
typescript
/**
* Reactive numeric projection from one domain to another.
*
* @see https://vueuse.org/useProjection
*/
export declare function useProjection(
input: MaybeComputedRef<number>,
fromDomain: MaybeComputedRef<readonly [number, number]>,
toDomain: MaybeComputedRef<readonly [number, number]>,
projector?: ProjectorFunction<number, number>
): ComputedRef<number>
/**
* Reactive numeric projection from one domain to another.
*
* @see https://vueuse.org/useProjection
*/
export declare function useProjection(
input: MaybeComputedRef<number>,
fromDomain: MaybeComputedRef<readonly [number, number]>,
toDomain: MaybeComputedRef<readonly [number, number]>,
projector?: ProjectorFunction<number, number>
): ComputedRef<number>
Source
Contributors
Anthony Fu
Curt Grimes
Wenlu Wang