✨ MAJOR FEATURES: • Auto-zoom intelligence với smart bounds fitting • Enhanced 3D GPS markers với pulsing effects • Professional route display với 6-layer rendering • Status-based parking icons với availability indicators • Production-ready build optimizations 🗺️ AUTO-ZOOM FEATURES: • Smart bounds fitting cho GPS + selected parking • Adaptive padding (50px) cho visual balance • Max zoom control (level 16) để tránh quá gần • Dynamic centering khi không có selection 🎨 ENHANCED VISUALS: • 3D GPS marker với multi-layer pulse effects • Advanced parking icons với status colors • Selection highlighting với animation • Dimming system cho non-selected items 🛣️ ROUTE SYSTEM: • OpenRouteService API integration • Multi-layer route rendering (glow, shadow, main, animated) • Real-time distance & duration calculation • Visual route info trong popup 📱 PRODUCTION READY: • SSR safe với dynamic imports • Build errors resolved • Global deployment via Vercel • Optimized performance 🌍 DEPLOYMENT: • Vercel: https://whatever-ctk2auuxr-phong12hexdockworks-projects.vercel.app • Bundle size: 22.8 kB optimized • Global CDN distribution • HTTPS enabled 💾 VERSION CONTROL: • MapView-v2.0.tsx backup created • MAPVIEW_VERSIONS.md documentation • Full version history tracking
53 lines
2.1 KiB
JavaScript
53 lines
2.1 KiB
JavaScript
import { useTransform } from './use-transform.mjs';
|
|
import { invariant, warning } from '../utils/errors.mjs';
|
|
import { useMotionValue } from './use-motion-value.mjs';
|
|
import { MotionContext } from '../context/MotionContext/index.mjs';
|
|
import { useContext } from 'react';
|
|
|
|
// Keep things reasonable and avoid scale: Infinity. In practise we might need
|
|
// to add another value, opacity, that could interpolate scaleX/Y [0,0.01] => [0,1]
|
|
// to simply hide content at unreasonable scales.
|
|
const maxScale = 100000;
|
|
const invertScale = (scale) => scale > 0.001 ? 1 / scale : maxScale;
|
|
let hasWarned = false;
|
|
/**
|
|
* Returns a `MotionValue` each for `scaleX` and `scaleY` that update with the inverse
|
|
* of their respective parent scales.
|
|
*
|
|
* This is useful for undoing the distortion of content when scaling a parent component.
|
|
*
|
|
* By default, `useInvertedScale` will automatically fetch `scaleX` and `scaleY` from the nearest parent.
|
|
* By passing other `MotionValue`s in as `useInvertedScale({ scaleX, scaleY })`, it will invert the output
|
|
* of those instead.
|
|
*
|
|
* ```jsx
|
|
* const MyComponent = () => {
|
|
* const { scaleX, scaleY } = useInvertedScale()
|
|
* return <motion.div style={{ scaleX, scaleY }} />
|
|
* }
|
|
* ```
|
|
*
|
|
* @deprecated
|
|
*/
|
|
function useInvertedScale(scale) {
|
|
let parentScaleX = useMotionValue(1);
|
|
let parentScaleY = useMotionValue(1);
|
|
const { visualElement } = useContext(MotionContext);
|
|
invariant(!!(scale || visualElement), "If no scale values are provided, useInvertedScale must be used within a child of another motion component.");
|
|
warning(hasWarned, "useInvertedScale is deprecated and will be removed in 3.0. Use the layout prop instead.");
|
|
hasWarned = true;
|
|
if (scale) {
|
|
parentScaleX = scale.scaleX || parentScaleX;
|
|
parentScaleY = scale.scaleY || parentScaleY;
|
|
}
|
|
else if (visualElement) {
|
|
parentScaleX = visualElement.getValue("scaleX", 1);
|
|
parentScaleY = visualElement.getValue("scaleY", 1);
|
|
}
|
|
const scaleX = useTransform(parentScaleX, invertScale);
|
|
const scaleY = useTransform(parentScaleY, invertScale);
|
|
return { scaleX, scaleY };
|
|
}
|
|
|
|
export { invertScale, useInvertedScale };
|