Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 39x 39x 10x 39x 8x 39x 3x 2x 2x 2x 2x 2x 2x 39x 39x 2x 2x 39x 1x 1x 39x 4x 4x 39x 2x 2x | import { distance, mix } from "popmotion" import { ResolvedValues } from "../../render/types" import { Axis, AxisDelta, Box, Delta } from "./types" export function calcLength(axis: Axis) { return axis.max - axis.min } export function isNear(value: number, target = 0, maxDistance = 0.01): boolean { return distance(value, target) < maxDistance } export function calcAxisDelta( delta: AxisDelta, source: Axis, target: Axis, origin: number = 0.5 ) { delta.origin = origin delta.originPoint = mix(source.min, source.max, delta.origin) delta.scale = calcLength(target) / calcLength(source) Iif (isNear(delta.scale, 1, 0.0001) || isNaN(delta.scale)) delta.scale = 1 delta.translate = mix(target.min, target.max, delta.origin) - delta.originPoint Iif (isNear(delta.translate) || isNaN(delta.translate)) delta.translate = 0 } export function calcBoxDelta( delta: Delta, source: Box, target: Box, origin?: ResolvedValues ): void { calcAxisDelta(delta.x, source.x, target.x, origin?.originX as number) calcAxisDelta(delta.y, source.y, target.y, origin?.originY as number) } export function calcRelativeAxis(target: Axis, relative: Axis, parent: Axis) { target.min = parent.min + relative.min target.max = target.min + calcLength(relative) } export function calcRelativeBox(target: Box, relative: Box, parent: Box) { calcRelativeAxis(target.x, relative.x, parent.x) calcRelativeAxis(target.y, relative.y, parent.y) } export function calcRelativeAxisPosition( target: Axis, layout: Axis, parent: Axis ) { target.min = layout.min - parent.min target.max = target.min + calcLength(layout) } export function calcRelativePosition(target: Box, layout: Box, parent: Box) { calcRelativeAxisPosition(target.x, layout.x, parent.x) calcRelativeAxisPosition(target.y, layout.y, parent.y) } |