@hunterchen/canvas 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/canvas/canvas.d.ts +29 -0
- package/dist/components/canvas/canvas.d.ts.map +1 -0
- package/dist/components/canvas/canvas.js +419 -0
- package/dist/components/canvas/canvas.js.map +1 -0
- package/dist/components/canvas/component.d.ts +47 -0
- package/dist/components/canvas/component.d.ts.map +1 -0
- package/dist/components/canvas/component.js +177 -0
- package/dist/components/canvas/component.js.map +1 -0
- package/dist/components/canvas/cursor.d.ts +8 -0
- package/dist/components/canvas/cursor.d.ts.map +1 -0
- package/dist/components/canvas/cursor.js +32 -0
- package/dist/components/canvas/cursor.js.map +1 -0
- package/dist/components/canvas/draggable.d.ts +21 -0
- package/dist/components/canvas/draggable.d.ts.map +1 -0
- package/dist/components/canvas/draggable.js +163 -0
- package/dist/components/canvas/draggable.js.map +1 -0
- package/dist/components/canvas/navbar/index.d.ts +19 -0
- package/dist/components/canvas/navbar/index.d.ts.map +1 -0
- package/dist/components/canvas/navbar/index.js +106 -0
- package/dist/components/canvas/navbar/index.js.map +1 -0
- package/dist/components/canvas/navbar/single-button.d.ts +17 -0
- package/dist/components/canvas/navbar/single-button.d.ts.map +1 -0
- package/dist/components/canvas/navbar/single-button.js +97 -0
- package/dist/components/canvas/navbar/single-button.js.map +1 -0
- package/dist/components/canvas/offest.d.ts +6 -0
- package/dist/components/canvas/offest.d.ts.map +1 -0
- package/dist/components/canvas/offest.js +12 -0
- package/dist/components/canvas/offest.js.map +1 -0
- package/dist/components/canvas/reset.d.ts +5 -0
- package/dist/components/canvas/reset.d.ts.map +1 -0
- package/dist/components/canvas/reset.js +7 -0
- package/dist/components/canvas/reset.js.map +1 -0
- package/dist/components/canvas/toolbar.d.ts +7 -0
- package/dist/components/canvas/toolbar.d.ts.map +1 -0
- package/dist/components/canvas/toolbar.js +28 -0
- package/dist/components/canvas/toolbar.js.map +1 -0
- package/dist/components/canvas/wrapper.d.ts +26 -0
- package/dist/components/canvas/wrapper.d.ts.map +1 -0
- package/dist/components/canvas/wrapper.js +107 -0
- package/dist/components/canvas/wrapper.js.map +1 -0
- package/dist/components/ui/FolderIcon.d.ts +9 -0
- package/dist/components/ui/FolderIcon.d.ts.map +1 -0
- package/dist/components/ui/FolderIcon.js +25 -0
- package/dist/components/ui/FolderIcon.js.map +1 -0
- package/dist/components/ui/button.d.ts +14 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +54 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/label.d.ts +6 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +10 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/toast.d.ts +16 -0
- package/dist/components/ui/toast.d.ts.map +1 -0
- package/dist/components/ui/toast.js +41 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/toaster.d.ts +2 -0
- package/dist/components/ui/toaster.d.ts.map +1 -0
- package/dist/components/ui/toaster.js +10 -0
- package/dist/components/ui/toaster.js.map +1 -0
- package/dist/contexts/CanvasContext.d.ts +26 -0
- package/dist/contexts/CanvasContext.d.ts.map +1 -0
- package/dist/contexts/CanvasContext.js +22 -0
- package/dist/contexts/CanvasContext.js.map +1 -0
- package/dist/contexts/PerformanceContext.d.ts +31 -0
- package/dist/contexts/PerformanceContext.d.ts.map +1 -0
- package/dist/contexts/PerformanceContext.js +56 -0
- package/dist/contexts/PerformanceContext.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +16 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/hooks/use-toast.d.ts +45 -0
- package/dist/hooks/use-toast.d.ts.map +1 -0
- package/dist/hooks/use-toast.js +126 -0
- package/dist/hooks/use-toast.js.map +1 -0
- package/dist/hooks/usePerformanceMode.d.ts +6 -0
- package/dist/hooks/usePerformanceMode.d.ts.map +1 -0
- package/dist/hooks/usePerformanceMode.js +6 -0
- package/dist/hooks/usePerformanceMode.js.map +1 -0
- package/dist/hooks/useWindowDimensions.d.ts +7 -0
- package/dist/hooks/useWindowDimensions.d.ts.map +1 -0
- package/dist/hooks/useWindowDimensions.js +22 -0
- package/dist/hooks/useWindowDimensions.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/canvas.d.ts +35 -0
- package/dist/lib/canvas.d.ts.map +1 -0
- package/dist/lib/canvas.js +82 -0
- package/dist/lib/canvas.js.map +1 -0
- package/dist/lib/constants.d.ts +78 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +122 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/copy.d.ts +2 -0
- package/dist/lib/copy.d.ts.map +1 -0
- package/dist/lib/copy.js +20 -0
- package/dist/lib/copy.js.map +1 -0
- package/dist/lib/utils.d.ts +4 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +14 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +14 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/performance.d.ts +9 -0
- package/dist/utils/performance.d.ts.map +1 -0
- package/dist/utils/performance.js +29 -0
- package/dist/utils/performance.js.map +1 -0
- package/package.json +55 -0
- package/src/components/canvas/canvas.tsx +728 -0
- package/src/components/canvas/component.tsx +230 -0
- package/src/components/canvas/cursor.tsx +161 -0
- package/src/components/canvas/draggable.tsx +298 -0
- package/src/components/canvas/navbar/index.tsx +213 -0
- package/src/components/canvas/navbar/single-button.tsx +199 -0
- package/src/components/canvas/offest.tsx +23 -0
- package/src/components/canvas/reset.tsx +21 -0
- package/src/components/canvas/toolbar.tsx +67 -0
- package/src/components/canvas/wrapper.tsx +219 -0
- package/src/components/ui/FolderIcon.tsx +116 -0
- package/src/components/ui/button.tsx +162 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/toast.tsx +136 -0
- package/src/components/ui/toaster.tsx +33 -0
- package/src/contexts/CanvasContext.tsx +54 -0
- package/src/contexts/PerformanceContext.tsx +81 -0
- package/src/hooks/use-mobile.ts +21 -0
- package/src/hooks/use-toast.ts +186 -0
- package/src/hooks/usePerformanceMode.ts +5 -0
- package/src/hooks/useWindowDimensions.ts +32 -0
- package/src/index.ts +36 -0
- package/src/lib/canvas.ts +132 -0
- package/src/lib/constants.ts +153 -0
- package/src/lib/copy.ts +18 -0
- package/src/lib/utils.ts +18 -0
- package/src/types/index.ts +20 -0
- package/src/utils/performance.ts +37 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { animate } from "framer-motion";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { CANVAS_WIDTH, CANVAS_HEIGHT, MAX_DIM_RATIO, INTRO_ASPECT_RATIO, PAN_SPRING, ScreenSizeEnum, } from "./constants";
|
|
4
|
+
export const canvasWidth = CANVAS_WIDTH;
|
|
5
|
+
export const canvasHeight = CANVAS_HEIGHT;
|
|
6
|
+
// Re-export ScreenSizeEnum for backward compatibility
|
|
7
|
+
export { ScreenSizeEnum } from "./constants";
|
|
8
|
+
export const useMemoPoint = (x, y) => {
|
|
9
|
+
return useMemo(() => ({ x, y }), [x, y]);
|
|
10
|
+
};
|
|
11
|
+
export const getDistance = (p1, p2) => {
|
|
12
|
+
const dx = p1.clientX - p2.clientX;
|
|
13
|
+
const dy = p1.clientY - p2.clientY;
|
|
14
|
+
return Math.sqrt(dx ** 2 + dy ** 2);
|
|
15
|
+
};
|
|
16
|
+
export const getMidpoint = (p1, p2) => {
|
|
17
|
+
return {
|
|
18
|
+
x: (p1.clientX + p2.clientX) / 2,
|
|
19
|
+
y: (p1.clientY + p2.clientY) / 2,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export const getScreenSizeEnum = (width) => {
|
|
23
|
+
// iphone 12 pro is 390px, iphone 14 pro max is 430px, SE 3rd gen is 375px
|
|
24
|
+
if (width < 400)
|
|
25
|
+
return ScreenSizeEnum.SMALL_MOBILE;
|
|
26
|
+
if (width < 768)
|
|
27
|
+
return ScreenSizeEnum.MOBILE;
|
|
28
|
+
if (width < 1440)
|
|
29
|
+
return ScreenSizeEnum.TABLET;
|
|
30
|
+
if (width < 1920)
|
|
31
|
+
return ScreenSizeEnum.SMALL_DESKTOP;
|
|
32
|
+
if (width < 2560)
|
|
33
|
+
return ScreenSizeEnum.MEDIUM_DESKTOP;
|
|
34
|
+
if (width <= 3440)
|
|
35
|
+
return ScreenSizeEnum.LARGE_DESKTOP;
|
|
36
|
+
return ScreenSizeEnum.HUGE_DESKTOP;
|
|
37
|
+
};
|
|
38
|
+
export function getSectionPanCoordinates({ windowDimensions, coords, targetZoom, negative, }) {
|
|
39
|
+
const { width, height } = windowDimensions;
|
|
40
|
+
// Calculate the center of the section
|
|
41
|
+
const sectionCenterX = coords.x + coords.width / 2;
|
|
42
|
+
const sectionCenterY = coords.y + coords.height / 2;
|
|
43
|
+
// Calculate the required pan offset to center the section in the viewport
|
|
44
|
+
const targetX = width / 2 - sectionCenterX * targetZoom;
|
|
45
|
+
const targetY = height / 2 - sectionCenterY * targetZoom;
|
|
46
|
+
if (negative) {
|
|
47
|
+
return {
|
|
48
|
+
x: -targetX,
|
|
49
|
+
y: -targetY,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
x: targetX,
|
|
54
|
+
y: targetY,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export async function panToOffsetScene(offset, x, y, scale, newZoom) {
|
|
58
|
+
const animX = animate(x, offset.x, PAN_SPRING);
|
|
59
|
+
const animY = animate(y, offset.y, PAN_SPRING);
|
|
60
|
+
const animScale = animate(scale, newZoom ?? 1, PAN_SPRING);
|
|
61
|
+
await Promise.all([animScale, animX, animY]);
|
|
62
|
+
}
|
|
63
|
+
export const calcInitialBoxWidth = (windowWidth, windowHeight) => {
|
|
64
|
+
// math CanvasWrapper's bounding box size and compute scale s.t. canvas fits entirely within
|
|
65
|
+
const maxWidth = windowWidth * MAX_DIM_RATIO.width;
|
|
66
|
+
const maxHeight = windowHeight * MAX_DIM_RATIO.height;
|
|
67
|
+
let boxWidth, boxHeight;
|
|
68
|
+
if (maxWidth / INTRO_ASPECT_RATIO <= maxHeight) {
|
|
69
|
+
boxWidth = maxWidth;
|
|
70
|
+
boxHeight = boxWidth / INTRO_ASPECT_RATIO;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
boxHeight = maxHeight;
|
|
74
|
+
boxWidth = boxHeight * INTRO_ASPECT_RATIO;
|
|
75
|
+
}
|
|
76
|
+
// scale so the canvas fits inside the computed 3:2 box
|
|
77
|
+
return Math.min(boxWidth / canvasWidth, boxHeight / canvasHeight);
|
|
78
|
+
};
|
|
79
|
+
// Re-export commonly used constants for backward compatibility
|
|
80
|
+
export { MAX_DIM_RATIO } from "./constants";
|
|
81
|
+
export { INTERACTIVE_SELECTOR, ZOOM_BOUND, MAX_ZOOM, MIN_ZOOMS, } from "./constants";
|
|
82
|
+
//# sourceMappingURL=canvas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas.js","sourceRoot":"","sources":["../../src/lib/canvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAgC,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AACxC,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;AAE1C,sDAAsD;AACtD,OAAO,EAA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CAAC,CAAC;IAC3D,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,WAAmB,EACnB,YAAoB,EACpB,EAAE;IACF,4FAA4F;IAC5F,MAAM,QAAQ,GAAG,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC;IACnD,MAAM,SAAS,GAAG,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC;IAEtD,IAAI,QAAQ,EAAE,SAAS,CAAC;IAExB,IAAI,QAAQ,GAAG,kBAAkB,IAAI,SAAS,EAAE,CAAC;QAC/C,QAAQ,GAAG,QAAQ,CAAC;QACpB,SAAS,GAAG,QAAQ,GAAG,kBAAkB,CAAC;IAC5C,CAAC;SAAM,CAAC;QACN,SAAS,GAAG,SAAS,CAAC;QACtB,QAAQ,GAAG,SAAS,GAAG,kBAAkB,CAAC;IAC5C,CAAC;IAED,uDAAuD;IACvD,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,WAAW,EAAE,SAAS,GAAG,YAAY,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF,+DAA+D;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,QAAQ,EACR,SAAS,GACV,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type Easing } from "framer-motion";
|
|
2
|
+
/**
|
|
3
|
+
* Canvas Library Constants
|
|
4
|
+
* All configurable constants consolidated in one place
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ScreenSizeEnum {
|
|
7
|
+
SMALL_MOBILE = "small-mobile",
|
|
8
|
+
MOBILE = "mobile",
|
|
9
|
+
TABLET = "tablet",
|
|
10
|
+
SMALL_DESKTOP = "small-desktop",
|
|
11
|
+
MEDIUM_DESKTOP = "medium-desktop",
|
|
12
|
+
LARGE_DESKTOP = "large-desktop",
|
|
13
|
+
HUGE_DESKTOP = "huge-desktop"
|
|
14
|
+
}
|
|
15
|
+
/** Default canvas width in pixels */
|
|
16
|
+
export declare const CANVAS_WIDTH = 6000;
|
|
17
|
+
/** Default canvas height in pixels */
|
|
18
|
+
export declare const CANVAS_HEIGHT = 4000;
|
|
19
|
+
/** Maximum dimensions ratio for the intro box relative to viewport */
|
|
20
|
+
export declare const MAX_DIM_RATIO: {
|
|
21
|
+
readonly width: 0.8;
|
|
22
|
+
readonly height: 0.5;
|
|
23
|
+
};
|
|
24
|
+
/** Intro box aspect ratio (width:height) */
|
|
25
|
+
export declare const INTRO_ASPECT_RATIO: number;
|
|
26
|
+
/** Grow animation transition config */
|
|
27
|
+
export declare const GROW_TRANSITION: {
|
|
28
|
+
readonly duration: 0.96;
|
|
29
|
+
readonly delay: 3.14;
|
|
30
|
+
readonly ease: Easing;
|
|
31
|
+
};
|
|
32
|
+
/** Blur mask animation transition config */
|
|
33
|
+
export declare const BLUR_TRANSITION: {
|
|
34
|
+
readonly duration: 0.85;
|
|
35
|
+
readonly delay: 1.25;
|
|
36
|
+
readonly ease: Easing;
|
|
37
|
+
};
|
|
38
|
+
/** Stage 2 pan-to-home transition config */
|
|
39
|
+
export declare const STAGE2_TRANSITION: {
|
|
40
|
+
readonly duration: 0.96;
|
|
41
|
+
readonly ease: readonly [0.37, 0.1, 0.6, 1];
|
|
42
|
+
};
|
|
43
|
+
/** Maximum zoom level */
|
|
44
|
+
export declare const MAX_ZOOM = 3;
|
|
45
|
+
/** Minimum zoom bound multiplier to prevent zooming out past canvas edges */
|
|
46
|
+
export declare const ZOOM_BOUND = 1.05;
|
|
47
|
+
/** Minimum zoom levels per screen size */
|
|
48
|
+
export declare const MIN_ZOOMS: Record<ScreenSizeEnum, number>;
|
|
49
|
+
/** Pan animation spring config */
|
|
50
|
+
export declare const PAN_SPRING: {
|
|
51
|
+
readonly visualDuration: 0.34;
|
|
52
|
+
readonly type: "spring";
|
|
53
|
+
readonly stiffness: 200;
|
|
54
|
+
readonly damping: 25;
|
|
55
|
+
};
|
|
56
|
+
/** Wheel zoom sensitivity for mouse wheel */
|
|
57
|
+
export declare const MOUSE_WHEEL_ZOOM_SENSITIVITY = 0.0015;
|
|
58
|
+
/** Wheel zoom sensitivity for trackpad */
|
|
59
|
+
export declare const TRACKPAD_ZOOM_SENSITIVITY = 0.015;
|
|
60
|
+
/** CSS selector for interactive elements that should not trigger pan */
|
|
61
|
+
export declare const INTERACTIVE_SELECTOR: string;
|
|
62
|
+
/** Buffer zone in pixels for hysteresis visibility detection */
|
|
63
|
+
export declare const VIEWPORT_HYSTERESIS_BUFFER = 120;
|
|
64
|
+
/** Threshold for showing image fallback on smaller screens */
|
|
65
|
+
export declare const IMAGE_FALLBACK_WIDTH_THRESHOLD = 2000;
|
|
66
|
+
/** Responsive zoom levels for navbar navigation per screen size */
|
|
67
|
+
export declare const RESPONSIVE_ZOOM_MAP: Record<ScreenSizeEnum, number>;
|
|
68
|
+
/** Debounce duration in ms for navbar clicks based on performance mode */
|
|
69
|
+
export declare const NAVBAR_DEBOUNCE_MS: {
|
|
70
|
+
readonly high: 0;
|
|
71
|
+
readonly medium: 100;
|
|
72
|
+
readonly low: 400;
|
|
73
|
+
};
|
|
74
|
+
/** Epsilon for position comparison to hide toolbar when at home */
|
|
75
|
+
export declare const TOOLBAR_OPACITY_POS_EPS = 1;
|
|
76
|
+
/** Epsilon for scale comparison to hide toolbar when at 1x */
|
|
77
|
+
export declare const TOOLBAR_OPACITY_SCALE_EPS = 0.01;
|
|
78
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AAMH,oBAAY,cAAc;IACtB,YAAY,iBAAiB;I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O,MAAM,uBAAuB,IAAI,CAAC;AAEzC,8DAA8D;AAC9D,eAAO,MAAM,yBAAyB,OAAO,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas Library Constants
|
|
3
|
+
* All configurable constants consolidated in one place
|
|
4
|
+
*/
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// SCREEN SIZE BREAKPOINTS
|
|
7
|
+
// ============================================================================
|
|
8
|
+
export var ScreenSizeEnum;
|
|
9
|
+
(function (ScreenSizeEnum) {
|
|
10
|
+
ScreenSizeEnum["SMALL_MOBILE"] = "small-mobile";
|
|
11
|
+
ScreenSizeEnum["MOBILE"] = "mobile";
|
|
12
|
+
ScreenSizeEnum["TABLET"] = "tablet";
|
|
13
|
+
ScreenSizeEnum["SMALL_DESKTOP"] = "small-desktop";
|
|
14
|
+
ScreenSizeEnum["MEDIUM_DESKTOP"] = "medium-desktop";
|
|
15
|
+
ScreenSizeEnum["LARGE_DESKTOP"] = "large-desktop";
|
|
16
|
+
ScreenSizeEnum["HUGE_DESKTOP"] = "huge-desktop";
|
|
17
|
+
})(ScreenSizeEnum || (ScreenSizeEnum = {}));
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// CANVAS DIMENSIONS
|
|
20
|
+
// ============================================================================
|
|
21
|
+
/** Default canvas width in pixels */
|
|
22
|
+
export const CANVAS_WIDTH = 6000;
|
|
23
|
+
/** Default canvas height in pixels */
|
|
24
|
+
export const CANVAS_HEIGHT = 4000;
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// INTRO ANIMATION
|
|
27
|
+
// ============================================================================
|
|
28
|
+
/** Maximum dimensions ratio for the intro box relative to viewport */
|
|
29
|
+
export const MAX_DIM_RATIO = {
|
|
30
|
+
width: 0.8,
|
|
31
|
+
height: 0.5,
|
|
32
|
+
};
|
|
33
|
+
/** Intro box aspect ratio (width:height) */
|
|
34
|
+
export const INTRO_ASPECT_RATIO = 3 / 2;
|
|
35
|
+
/** Grow animation transition config */
|
|
36
|
+
export const GROW_TRANSITION = {
|
|
37
|
+
duration: 0.96,
|
|
38
|
+
delay: 3.14,
|
|
39
|
+
ease: [0.35, 0.1, 0.8, 1],
|
|
40
|
+
};
|
|
41
|
+
/** Blur mask animation transition config */
|
|
42
|
+
export const BLUR_TRANSITION = {
|
|
43
|
+
duration: 0.85,
|
|
44
|
+
delay: 1.25,
|
|
45
|
+
ease: "easeIn",
|
|
46
|
+
};
|
|
47
|
+
/** Stage 2 pan-to-home transition config */
|
|
48
|
+
export const STAGE2_TRANSITION = {
|
|
49
|
+
duration: 0.96,
|
|
50
|
+
ease: [0.37, 0.1, 0.6, 1],
|
|
51
|
+
};
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// ZOOM & PAN
|
|
54
|
+
// ============================================================================
|
|
55
|
+
/** Maximum zoom level */
|
|
56
|
+
export const MAX_ZOOM = 3;
|
|
57
|
+
/** Minimum zoom bound multiplier to prevent zooming out past canvas edges */
|
|
58
|
+
export const ZOOM_BOUND = 1.05;
|
|
59
|
+
/** Minimum zoom levels per screen size */
|
|
60
|
+
export const MIN_ZOOMS = {
|
|
61
|
+
[ScreenSizeEnum.SMALL_MOBILE]: 0.3,
|
|
62
|
+
[ScreenSizeEnum.MOBILE]: 0.35,
|
|
63
|
+
[ScreenSizeEnum.TABLET]: 0.25,
|
|
64
|
+
[ScreenSizeEnum.SMALL_DESKTOP]: 0.15,
|
|
65
|
+
[ScreenSizeEnum.MEDIUM_DESKTOP]: 0.1,
|
|
66
|
+
[ScreenSizeEnum.LARGE_DESKTOP]: 0.1,
|
|
67
|
+
[ScreenSizeEnum.HUGE_DESKTOP]: 0.1,
|
|
68
|
+
};
|
|
69
|
+
/** Pan animation spring config */
|
|
70
|
+
export const PAN_SPRING = {
|
|
71
|
+
visualDuration: 0.34,
|
|
72
|
+
type: "spring",
|
|
73
|
+
stiffness: 200,
|
|
74
|
+
damping: 25,
|
|
75
|
+
};
|
|
76
|
+
/** Wheel zoom sensitivity for mouse wheel */
|
|
77
|
+
export const MOUSE_WHEEL_ZOOM_SENSITIVITY = 0.0015;
|
|
78
|
+
/** Wheel zoom sensitivity for trackpad */
|
|
79
|
+
export const TRACKPAD_ZOOM_SENSITIVITY = 0.015;
|
|
80
|
+
// ============================================================================
|
|
81
|
+
// INTERACTIONS
|
|
82
|
+
// ============================================================================
|
|
83
|
+
/** CSS selector for interactive elements that should not trigger pan */
|
|
84
|
+
export const INTERACTIVE_SELECTOR = "button,[role='button'],input,textarea,[contenteditable='true']," +
|
|
85
|
+
"[data-toolbar-button],[data-navbar-button]";
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// VIEWPORT CULLING
|
|
88
|
+
// ============================================================================
|
|
89
|
+
/** Buffer zone in pixels for hysteresis visibility detection */
|
|
90
|
+
export const VIEWPORT_HYSTERESIS_BUFFER = 120;
|
|
91
|
+
/** Threshold for showing image fallback on smaller screens */
|
|
92
|
+
export const IMAGE_FALLBACK_WIDTH_THRESHOLD = 2000;
|
|
93
|
+
// ============================================================================
|
|
94
|
+
// NAVBAR
|
|
95
|
+
// ============================================================================
|
|
96
|
+
/** Responsive zoom levels for navbar navigation per screen size */
|
|
97
|
+
export const RESPONSIVE_ZOOM_MAP = {
|
|
98
|
+
[ScreenSizeEnum.SMALL_MOBILE]: 0.5,
|
|
99
|
+
[ScreenSizeEnum.MOBILE]: 0.6,
|
|
100
|
+
[ScreenSizeEnum.TABLET]: 0.8,
|
|
101
|
+
[ScreenSizeEnum.SMALL_DESKTOP]: 0.9,
|
|
102
|
+
[ScreenSizeEnum.MEDIUM_DESKTOP]: 1,
|
|
103
|
+
[ScreenSizeEnum.LARGE_DESKTOP]: 1.25,
|
|
104
|
+
[ScreenSizeEnum.HUGE_DESKTOP]: 1.5,
|
|
105
|
+
};
|
|
106
|
+
// ============================================================================
|
|
107
|
+
// PERFORMANCE
|
|
108
|
+
// ============================================================================
|
|
109
|
+
/** Debounce duration in ms for navbar clicks based on performance mode */
|
|
110
|
+
export const NAVBAR_DEBOUNCE_MS = {
|
|
111
|
+
high: 0,
|
|
112
|
+
medium: 100,
|
|
113
|
+
low: 400,
|
|
114
|
+
};
|
|
115
|
+
// ============================================================================
|
|
116
|
+
// TOOLBAR
|
|
117
|
+
// ============================================================================
|
|
118
|
+
/** Epsilon for position comparison to hide toolbar when at home */
|
|
119
|
+
export const TOOLBAR_OPACITY_POS_EPS = 1; // px
|
|
120
|
+
/** Epsilon for scale comparison to hide toolbar when at 1x */
|
|
121
|
+
export const TOOLBAR_OPACITY_SCALE_EPS = 0.01; // scale delta
|
|
122
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E,MAAM,CAAN,IAAY,cAQX;AARD,WAAY,cAAc;IACtB,+CAA6B,CAAA;IAC7B,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;IACjB,iDAA+B,CAAA;IAC/B,mDAAiC,CAAA;IACjC,iDAA+B,CAAA;IAC/B,+CAA6B,CAAA;AACjC,CAAC,EARW,cAAc,KAAd,cAAc,QAQzB;AAED,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E,qCAAqC;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AAEjC,sCAAsC;AACtC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AAElC,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,sEAAsE;AACtE,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,GAAG;CACL,CAAC;AAEX,4CAA4C;AAC5C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAG,CAAC,CAAC;AAExC,uCAAuC;AACvC,MAAM,CAAC,MAAM,eAAe,GAAG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
|
1
|
+
{"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../../src/lib/copy.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,OAAO,CAiB5D,CAAC"}
|
package/dist/lib/copy.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const copyText = async (text) => {
|
|
2
|
+
try {
|
|
3
|
+
if (navigator.clipboard?.writeText && window.isSecureContext) {
|
|
4
|
+
await navigator.clipboard.writeText(text);
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
// fallback: execCommand
|
|
8
|
+
const ta = document.createElement("textarea");
|
|
9
|
+
ta.value = text;
|
|
10
|
+
document.body.appendChild(ta);
|
|
11
|
+
ta.select();
|
|
12
|
+
const ok = document.execCommand("copy");
|
|
13
|
+
document.body.removeChild(ta);
|
|
14
|
+
return ok;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy.js","sourceRoot":"","sources":["../../src/lib/copy.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAY,EAAoB,EAAE;IAC/D,IAAI,CAAC;QACH,IAAI,SAAS,CAAC,SAAS,EAAE,SAAS,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;YAC7D,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC;QACd,CAAC;QACD,wBAAwB;QACxB,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAC9C,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC;QAChB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAC9B,EAAE,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,EAAE,GAAG,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACxC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAC9B,OAAO,EAAE,CAAC;IACZ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAC;AAG7C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,EAC7D,EAAE,EAAE,CAAC,EACL,IAAI,SAAK,GAOU,CAAC,CACrB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
export function cn(...inputs) {
|
|
4
|
+
return twMerge(clsx(inputs));
|
|
5
|
+
}
|
|
6
|
+
export function debounce(cb, wait = 20) {
|
|
7
|
+
let h = 0;
|
|
8
|
+
const callable = (...args) => {
|
|
9
|
+
clearTimeout(h);
|
|
10
|
+
h = setTimeout(() => cb(...args), wait);
|
|
11
|
+
};
|
|
12
|
+
return callable;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,MAAM,UAAU,EAAE,CAAC,GAAG,MAAoB;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,QAAQ,CACtB,EAAK,EACL,IAAI,GAAG,EAAE;IAET,IAAI,CAAC,GAA4B,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE;QACtC,YAAY,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC,CAAC;IACF,OAAO,QAAa,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic types for the canvas library
|
|
3
|
+
* Apps should extend these types with their specific enums and constants
|
|
4
|
+
*/
|
|
5
|
+
export interface SectionCoordinates {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
export declare enum CanvasSection {
|
|
12
|
+
Home = "home",
|
|
13
|
+
About = "about",
|
|
14
|
+
Projects = "projects",
|
|
15
|
+
Sponsors = "sponsors",
|
|
16
|
+
FAQ = "faq",
|
|
17
|
+
Team = "team"
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,kBAAkB;IACjC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,GAAG,QAAQ;IACX,IAAI,SAAS;CACd"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic types for the canvas library
|
|
3
|
+
* Apps should extend these types with their specific enums and constants
|
|
4
|
+
*/
|
|
5
|
+
export var CanvasSection;
|
|
6
|
+
(function (CanvasSection) {
|
|
7
|
+
CanvasSection["Home"] = "home";
|
|
8
|
+
CanvasSection["About"] = "about";
|
|
9
|
+
CanvasSection["Projects"] = "projects";
|
|
10
|
+
CanvasSection["Sponsors"] = "sponsors";
|
|
11
|
+
CanvasSection["FAQ"] = "faq";
|
|
12
|
+
CanvasSection["Team"] = "team";
|
|
13
|
+
})(CanvasSection || (CanvasSection = {}));
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,MAAM,CAAN,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,gCAAe,CAAA;IACf,sCAAqB,CAAA;IACrB,sCAAqB,CAAA;IACrB,4BAAW,CAAA;IACX,8BAAa,CAAA;AACf,CAAC,EAPW,aAAa,KAAb,aAAa,QAOxB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance optimization utilities for cross-platform compatibility
|
|
3
|
+
* Particularly focused on iOS Safari performance issues
|
|
4
|
+
*/
|
|
5
|
+
export declare const isIOS: () => boolean;
|
|
6
|
+
export declare const isMobile: () => boolean;
|
|
7
|
+
export declare const prefersReducedMotion: () => boolean;
|
|
8
|
+
export declare const getWillChange: (isAnimating: boolean, properties?: string[]) => string;
|
|
9
|
+
//# sourceMappingURL=performance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../src/utils/performance.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,KAAK,QAAO,OAIxB,CAAC;AAGF,eAAO,MAAM,QAAQ,QAAO,OAM3B,CAAC;AAGF,eAAO,MAAM,oBAAoB,QAAO,OAIvC,CAAC;AAGF,eAAO,MAAM,aAAa,GACxB,aAAa,OAAO,EACpB,aAAY,MAAM,EAAkB,KACnC,MAIF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance optimization utilities for cross-platform compatibility
|
|
3
|
+
* Particularly focused on iOS Safari performance issues
|
|
4
|
+
*/
|
|
5
|
+
// Detect if the device is iOS
|
|
6
|
+
export const isIOS = () => {
|
|
7
|
+
if (typeof window === "undefined")
|
|
8
|
+
return false;
|
|
9
|
+
return /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
10
|
+
};
|
|
11
|
+
// Detect if the device is a mobile device
|
|
12
|
+
export const isMobile = () => {
|
|
13
|
+
if (typeof window === "undefined")
|
|
14
|
+
return false;
|
|
15
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
16
|
+
};
|
|
17
|
+
// Check if user prefers reduced motion
|
|
18
|
+
export const prefersReducedMotion = () => {
|
|
19
|
+
if (typeof window === "undefined")
|
|
20
|
+
return false;
|
|
21
|
+
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
22
|
+
};
|
|
23
|
+
// Get optimized will-change value based on state
|
|
24
|
+
export const getWillChange = (isAnimating, properties = ["transform"]) => {
|
|
25
|
+
// Only apply will-change when actually animating
|
|
26
|
+
// Leaving it on causes memory issues on iOS
|
|
27
|
+
return isAnimating ? properties.join(", ") : "auto";
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=performance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance.js","sourceRoot":"","sources":["../../src/utils/performance.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8BAA8B;AAC9B,MAAM,CAAC,MAAM,KAAK,GAAG,GAAY,EAAE;IACjC,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IAEhD,OAAO,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;AACtD,CAAC,CAAC;AAEF,0CAA0C;AAC1C,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAY,EAAE;IACpC,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IAEhD,OAAO,gEAAgE,CAAC,IAAI,CAC1E,SAAS,CAAC,SAAS,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,uCAAuC;AACvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAY,EAAE;IAChD,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IAEhD,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC,CAAC;AAEF,iDAAiD;AACjD,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,WAAoB,EACpB,aAAuB,CAAC,WAAW,CAAC,EAC5B,EAAE;IACV,iDAAiD;IACjD,4CAA4C;IAC5C,OAAO,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AACtD,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hunterchen/canvas",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A React-based canvas library for creating pannable, zoomable, and interactive canvas experiences.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"src"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./components": {
|
|
19
|
+
"types": "./dist/components/index.d.ts",
|
|
20
|
+
"default": "./dist/components/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./contexts": {
|
|
23
|
+
"types": "./dist/contexts/index.d.ts",
|
|
24
|
+
"default": "./dist/contexts/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./hooks": {
|
|
27
|
+
"types": "./dist/hooks/index.d.ts",
|
|
28
|
+
"default": "./dist/hooks/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./lib": {
|
|
31
|
+
"types": "./dist/lib/index.d.ts",
|
|
32
|
+
"default": "./dist/lib/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"type-check": "tsc --noEmit",
|
|
38
|
+
"clean": "rm -rf dist"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"framer-motion": "^11.0.0 || ^12.0.0",
|
|
42
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
43
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"lucide-react": "^0.483.0",
|
|
47
|
+
"tailwindcss": "^3.4.19"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^25.0.6",
|
|
51
|
+
"@types/react": "19.0.12",
|
|
52
|
+
"@types/react-dom": "19.0.4",
|
|
53
|
+
"typescript": "^5.8.2"
|
|
54
|
+
}
|
|
55
|
+
}
|