Skip to content

createProjection ​

Category
Export Size
193 B
Package
@vueuse/math
Last Changed
2 months ago
Related

Reactive numeric projection from one domain to another.

Usage ​

ts
import { createProjection } from '@vueuse/math'

const useProjector = createProjection([0, 10], [0, 100])
const input = ref(0)
const projected = useProjector(input) // projected.value === 0

input.value = 5 // projected.value === 50
input.value = 10 // projected.value === 100

Type Declarations ​

typescript
export declare function createProjection(
  fromDomain: MaybeRefOrGetter<readonly [number, number]>,
  toDomain: MaybeRefOrGetter<readonly [number, number]>,
  projector?: ProjectorFunction<number, number>,
): UseProjection<number, number>

Source ​

Source • Docs

Contributors ​

Anthony Fu
Anthony Fu

Changelog ​

v10.0.0-beta.4 on 4/13/2023
4d757 - feat(types)!: rename MaybeComputedRef to MaybeRefOrGetter

Released under the MIT License.