@deepnoid/canvas 0.1.4 → 0.1.5

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.
@@ -19,8 +19,6 @@ type Props = {
19
19
  };
20
20
  onImageLoadError?: (error: Error) => void;
21
21
  onImageLoadSuccess?: () => void;
22
- renderLoading?: () => ReactNode;
23
- renderError?: (errorMessage: string, retry: () => void) => ReactNode;
24
22
  };
25
- declare const XrayViewer: ({ image, hasZoom, coordinates, onImageLoadError, onImageLoadSuccess, renderLoading, renderError, }: Props) => import("react/jsx-runtime").JSX.Element;
23
+ declare const XrayViewer: ({ image, hasZoom, coordinates, onImageLoadError, onImageLoadSuccess }: Props) => import("react/jsx-runtime").JSX.Element;
26
24
  export default XrayViewer;
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
4
4
  import useResizeObserver from '../hooks/useResizeObserver';
5
5
  import { canvasCenterPoint, drawCanvas, getMousePointTransform, resolutionCanvas } from '../utils/graphic';
6
6
  import Canvas from './Canvas';
7
- const XrayViewer = ({ image, hasZoom, coordinates, onImageLoadError, onImageLoadSuccess, renderLoading, renderError, }) => {
7
+ const XrayViewer = ({ image, hasZoom, coordinates, onImageLoadError, onImageLoadSuccess }) => {
8
8
  const wrapper = useRef(null);
9
9
  const viewer = useRef(null);
10
10
  const { width, height } = useResizeObserver({ ref: viewer });
@@ -251,15 +251,6 @@ const XrayViewer = ({ image, hasZoom, coordinates, onImageLoadError, onImageLoad
251
251
  setStatus('STOP');
252
252
  event.preventDefault();
253
253
  };
254
- const renderOverlay = () => {
255
- if (isImageLoading) {
256
- return renderLoading?.() || _jsx("div", { children: "\uC774\uBBF8\uC9C0 \uB85C\uB529 \uC911..." });
257
- }
258
- if (imageError) {
259
- return (renderError?.(imageError, initCanvas) || (_jsxs("div", { children: ["\uC774\uBBF8\uC9C0 \uB85C\uB4DC \uC2E4\uD328", _jsx("button", { onClick: initCanvas, children: "\uB2E4\uC2DC \uC2DC\uB3C4" })] })));
260
- }
261
- return null;
262
- };
263
254
  return (_jsx("div", { style: { width: '100%', height: '100%', display: 'flex', flex: 1, backgroundColor: '#f5f5f5' }, children: _jsxs("div", { ref: wrapper, onWheel: handleWheel, onMouseMove: handleMouseMove, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onMouseLeave: handleMouseLeave, style: { flex: 1, position: 'relative' }, children: [_jsx("canvas", { ref: viewer, style: {
264
255
  position: 'absolute',
265
256
  width: '100%',
@@ -268,6 +259,6 @@ const XrayViewer = ({ image, hasZoom, coordinates, onImageLoadError, onImageLoad
268
259
  top: 0,
269
260
  transition: 'all 500ms',
270
261
  opacity: isImageLoading || imageError ? 0.5 : 1,
271
- } }), renderOverlay(), !isImageLoading && !imageError && (_jsx(Canvas, { moveX: moveX, moveY: moveY, zoomX: zoomX, zoomY: zoomY, zoom: zoom, dx: dx, dy: dy, dw: dw, dh: dh, coordinates: coordinates })), hasZoom && initZoom !== 0 && !isImageLoading && !imageError && (_jsx(hasZoom.ZoomButton, { onClick: initCanvas, children: `${Math.round((zoom / initZoom) * 100)}%` }))] }) }));
262
+ } }), !isImageLoading && !imageError && (_jsx(Canvas, { moveX: moveX, moveY: moveY, zoomX: zoomX, zoomY: zoomY, zoom: zoom, dx: dx, dy: dy, dw: dw, dh: dh, coordinates: coordinates })), hasZoom && initZoom !== 0 && !isImageLoading && !imageError && (_jsx(hasZoom.ZoomButton, { onClick: initCanvas, children: `${Math.round((zoom / initZoom) * 100)}%` }))] }) }));
272
263
  };
273
264
  export default XrayViewer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepnoid/canvas",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",