@shohojdhara/atomix 0.6.1 → 0.6.2
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/atomix.css +2 -0
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +1 -1
- package/dist/atomix.min.css.map +1 -1
- package/dist/atomix.umd.js +1 -1
- package/dist/atomix.umd.js.map +1 -1
- package/dist/atomix.umd.min.js +1 -1
- package/dist/charts.d.ts +9 -0
- package/dist/charts.js +43 -8
- package/dist/charts.js.map +1 -1
- package/dist/core.d.ts +9 -0
- package/dist/core.js +43 -8
- package/dist/core.js.map +1 -1
- package/dist/forms.d.ts +9 -0
- package/dist/forms.js +43 -8
- package/dist/forms.js.map +1 -1
- package/dist/heavy.d.ts +9 -0
- package/dist/heavy.js +43 -8
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.esm.js +43 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +43 -8
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AtomixGlass/deprecated/AtomixGlass.deprecated.tsx +390 -0
- package/src/lib/composables/shared-mouse-tracker.ts +62 -6
- package/src/lib/composables/useAtomixGlass.ts +4 -2
- package/src/lib/constants/components.ts +4 -0
- package/src/lib/types/components.ts +10 -4
- package/src/styles/06-components/_components.navbar.scss +2 -0
- package/src/lib/theme/devtools/DesignTokensCustomizer.stories.tsx +0 -215
package/dist/forms.d.ts
CHANGED
|
@@ -417,6 +417,15 @@ interface AtomixGlassProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
417
417
|
* @default false
|
|
418
418
|
*/
|
|
419
419
|
disableResponsiveBreakpoints?: boolean;
|
|
420
|
+
/**
|
|
421
|
+
* Priority level for rendering and performance scheduling
|
|
422
|
+
*
|
|
423
|
+
* Controls the rendering priority of the glass effect, allowing for performance
|
|
424
|
+
* optimization in complex scenes. Higher priority elements are rendered first.
|
|
425
|
+
*
|
|
426
|
+
* @default undefined
|
|
427
|
+
*/
|
|
428
|
+
priority?: number;
|
|
420
429
|
}
|
|
421
430
|
/**
|
|
422
431
|
* Common component size options
|
package/dist/forms.js
CHANGED
|
@@ -74,6 +74,10 @@ import React, { memo, forwardRef, useId, useMemo, useState, useRef, useEffect, u
|
|
|
74
74
|
MIN_BLUR: .1,
|
|
75
75
|
MOUSE_INFLUENCE_DIVISOR: 100,
|
|
76
76
|
EDGE_FADE_PIXELS: 2,
|
|
77
|
+
// Elasticity physics constants
|
|
78
|
+
ELASTICITY_TRANSLATION_FACTOR: .1,
|
|
79
|
+
ELASTICITY_DISTANCE_THRESHOLD: 200,
|
|
80
|
+
ELASTICITY_COMPRESSION_FACTOR: .3,
|
|
77
81
|
// Note: This default must match the SCSS variable --atomix-radius-md
|
|
78
82
|
// @see src/styles/01-settings/_settings.global.scss
|
|
79
83
|
DEFAULT_CORNER_RADIUS: 16,
|
|
@@ -769,9 +773,21 @@ class {
|
|
|
769
773
|
y: this.lastEvent.clientY
|
|
770
774
|
},
|
|
771
775
|
// Notify all subscribers
|
|
772
|
-
this.listeners.forEach((
|
|
776
|
+
this.listeners.forEach((listener => {
|
|
773
777
|
try {
|
|
774
|
-
|
|
778
|
+
// If the listener has an element, calculate distance-based attenuation
|
|
779
|
+
if (listener.element) {
|
|
780
|
+
const elementRect = listener.element.getBoundingClientRect(), elementCenter = {
|
|
781
|
+
x: elementRect.left + elementRect.width / 2,
|
|
782
|
+
y: elementRect.top + elementRect.height / 2
|
|
783
|
+
}, distance = this.calculateDistance(this.position, elementCenter), maxDistance = listener.maxDistance || 300, attenuation = Math.max(0, 1 - distance / maxDistance), attenuatedRelativePosition = {
|
|
784
|
+
x: (this.position.x - elementCenter.x) / elementRect.width * 100 * attenuation,
|
|
785
|
+
y: (this.position.y - elementCenter.y) / elementRect.height * 100 * attenuation
|
|
786
|
+
};
|
|
787
|
+
listener.callback(attenuatedRelativePosition);
|
|
788
|
+
} else
|
|
789
|
+
// Send original position for listeners without distance-based attenuation
|
|
790
|
+
listener.callback(this.position);
|
|
775
791
|
} catch (error) {
|
|
776
792
|
console.error("GlobalMouseTracker: Error in subscriber callback", error);
|
|
777
793
|
}
|
|
@@ -782,10 +798,17 @@ class {
|
|
|
782
798
|
/**
|
|
783
799
|
* Subscribe to mouse position updates
|
|
784
800
|
* @param callback Function to call when mouse position changes
|
|
801
|
+
* @param element Optional element for distance-based attenuation
|
|
802
|
+
* @param maxDistance Optional maximum distance for full effect
|
|
785
803
|
* @returns Unsubscribe function
|
|
786
|
-
*/ subscribe(callback) {
|
|
804
|
+
*/ subscribe(callback, element, maxDistance) {
|
|
805
|
+
const listener = {
|
|
806
|
+
callback: callback,
|
|
807
|
+
element: element,
|
|
808
|
+
maxDistance: maxDistance
|
|
809
|
+
};
|
|
787
810
|
// Return unsubscribe function
|
|
788
|
-
return this.listeners.add(
|
|
811
|
+
return this.listeners.add(listener),
|
|
789
812
|
// Start tracking if this is the first subscriber
|
|
790
813
|
1 === this.listeners.size && this.startTracking(),
|
|
791
814
|
// Immediately notify with current position
|
|
@@ -796,9 +819,13 @@ class {
|
|
|
796
819
|
/**
|
|
797
820
|
* Unsubscribe from mouse position updates
|
|
798
821
|
*/ unsubscribe(callback) {
|
|
799
|
-
|
|
822
|
+
// Find and remove the listener with the given callback
|
|
823
|
+
for (const listener of this.listeners) if (listener.callback === callback) {
|
|
824
|
+
this.listeners.delete(listener);
|
|
825
|
+
break;
|
|
826
|
+
}
|
|
800
827
|
// Stop tracking if no more subscribers
|
|
801
|
-
|
|
828
|
+
0 === this.listeners.size && this.stopTracking();
|
|
802
829
|
}
|
|
803
830
|
/**
|
|
804
831
|
* Start tracking mouse movement
|
|
@@ -817,6 +844,12 @@ class {
|
|
|
817
844
|
null !== this.rafId && (cancelAnimationFrame(this.rafId), this.rafId = null), this.lastEvent = null);
|
|
818
845
|
}
|
|
819
846
|
/**
|
|
847
|
+
* Calculate distance between two points
|
|
848
|
+
*/ calculateDistance(point1, point2) {
|
|
849
|
+
const dx = point1.x - point2.x, dy = point1.y - point2.y;
|
|
850
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
820
853
|
* Get current mouse position (synchronous)
|
|
821
854
|
*/ getPosition() {
|
|
822
855
|
return {
|
|
@@ -1101,7 +1134,8 @@ const {CONSTANTS: CONSTANTS} = ATOMIX_GLASS, backgroundDetectionCache = new Weak
|
|
|
1101
1134
|
* Composable hook for AtomixGlass component logic
|
|
1102
1135
|
* Manages all state, calculations, and event handlers
|
|
1103
1136
|
*/
|
|
1104
|
-
function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef: wrapperRef, borderRadius: borderRadius, globalMousePosition: externalGlobalMousePosition, mouseOffset: externalMouseOffset, mouseContainer: mouseContainer, overLight: overLight = ATOMIX_GLASS.DEFAULTS.OVER_LIGHT, reducedMotion: reducedMotion = !1, highContrast: highContrast = !1, withoutEffects: withoutEffects = !1, elasticity: elasticity = .
|
|
1137
|
+
function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef: wrapperRef, borderRadius: borderRadius, globalMousePosition: externalGlobalMousePosition, mouseOffset: externalMouseOffset, mouseContainer: mouseContainer, overLight: overLight = ATOMIX_GLASS.DEFAULTS.OVER_LIGHT, reducedMotion: reducedMotion = !1, highContrast: highContrast = !1, withoutEffects: withoutEffects = !1, elasticity: elasticity = ATOMIX_GLASS.DEFAULTS.ELASTICITY, onClick: onClick, debugBorderRadius: debugBorderRadius = !1, debugOverLight: debugOverLight = !1, children: children, blurAmount: blurAmount, saturation: saturation, padding: padding, withLiquidBlur: withLiquidBlur, isFixedOrSticky: isFixedOrSticky = !1, priority: priority = 1, withTimeAnimation:
|
|
1138
|
+
// Default priority
|
|
1105
1139
|
// Phase 1: Animation System Props
|
|
1106
1140
|
withTimeAnimation = ATOMIX_GLASS.DEFAULTS.WITH_TIME_ANIMATION, animationSpeed: animationSpeed = ATOMIX_GLASS.DEFAULTS.ANIMATION_SPEED, withMultiLayerDistortion: withMultiLayerDistortion = ATOMIX_GLASS.DEFAULTS.WITH_MULTI_LAYER_DISTORTION, distortionOctaves: distortionOctaves = ATOMIX_GLASS.DEFAULTS.DISTORTION_OCTAVES, distortionLacunarity: distortionLacunarity = ATOMIX_GLASS.DEFAULTS.DISTORTION_LACUNARITY, distortionGain: distortionGain = ATOMIX_GLASS.DEFAULTS.DISTORTION_GAIN, distortionQuality: distortionQuality = ATOMIX_GLASS.DEFAULTS.DISTORTION_QUALITY}) {
|
|
1107
1141
|
// State
|
|
@@ -1498,7 +1532,8 @@ withTimeAnimation = ATOMIX_GLASS.DEFAULTS.WITH_TIME_ANIMATION, animationSpeed: a
|
|
|
1498
1532
|
useEffect((() => {
|
|
1499
1533
|
if (externalGlobalMousePosition && externalMouseOffset) return;
|
|
1500
1534
|
if (effectiveWithoutEffects) return;
|
|
1501
|
-
const unsubscribe = globalMouseTracker.subscribe(handleGlobalMousePosition);
|
|
1535
|
+
const unsubscribe = globalMouseTracker.subscribe(handleGlobalMousePosition, glassRef.current || void 0, 300);
|
|
1536
|
+
// 300px max distance for full effect
|
|
1502
1537
|
// Initial start
|
|
1503
1538
|
startLerpLoop();
|
|
1504
1539
|
const container = mouseContainer?.current || glassRef.current;
|