Skip to content

Commit

Permalink
revert changes to SingleImageViewer
Browse files Browse the repository at this point in the history
  • Loading branch information
eatyourgreens committed Dec 6, 2024
1 parent 1cb33e9 commit 0e7a945
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ function SingleImageViewer({
zoomControlFn = null,
zooming = false
}) {
const canvasLayer = useRef()
const canvas = canvasLayer.current
const transform = `rotate(${rotate} ${width / 2} ${height / 2})`

return (
<SVGContext.Provider value={{ viewBox, rotate, width, height }}>
<SVGContext.Provider value={{ canvas, viewBox, rotate, width, height }}>
{zoomControlFn && (
<ZoomControlButton
onClick={zoomControlFn}
Expand Down Expand Up @@ -66,6 +68,7 @@ function SingleImageViewer({
transform={transform}
>
<SVGImageCanvas
ref={canvasLayer}
viewBox={viewBox}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ function createPoint(event) {

function getEventOffset(event, canvas) {
const svgPoint = createPoint(event)
const svgEventOffset = svgPoint.matrixTransform
? svgPoint.matrixTransform(canvas.getScreenCTM().inverse())
const ctm = canvas?.getScreenCTM()
const svgEventOffset = ctm && svgPoint.matrixTransform
? svgPoint.matrixTransform(ctm.inverse())
: svgPoint
return svgEventOffset
}
Expand Down

0 comments on commit 0e7a945

Please sign in to comment.