Skip to content
On this page

createProjection

Category
Export Size
264 B
Package
@vueuse/math
Last Changed
7 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
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: MaybeComputedRef<readonly [number, number]>,
  toDomain: MaybeComputedRef<readonly [number, number]>,
  projector?: ProjectorFunction<number, number>
): UseProjection<number, number>
export declare function createProjection(
  fromDomain: MaybeComputedRef<readonly [number, number]>,
  toDomain: MaybeComputedRef<readonly [number, number]>,
  projector?: ProjectorFunction<number, number>
): UseProjection<number, number>

Source

SourceDocs

Contributors

Anthony Fu

Changelog

v8.9.2 on 7/12/2022
0de42 - feat(useProjection)!: rework useProjection (#1822)

Released under the MIT License.