Skip to content

Commit

Permalink
feat: add className option to zoom image move ✨ (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
willnguyen1312 authored Oct 5, 2024
1 parent 8e440e7 commit 416a0be
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-dots-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zoom-image/core": minor
---

feat: add className option to zoom image move ✨
4 changes: 3 additions & 1 deletion packages/core/src/createZoomImageMove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type ZoomImageMoveOptions = {
disabledContextMenu?: boolean
zoomImageProps?: {
alt?: string
className?: string
}
}

Expand All @@ -34,7 +35,8 @@ export function createZoomImageMove(container: HTMLElement, options: ZoomImageMo
})

const zoomedImg = document.createElement("img")
zoomedImg.alt = options.zoomImageProps?.alt || ""
options.zoomImageProps?.alt && (zoomedImg.alt = options.zoomImageProps.alt)
options.zoomImageProps?.className && (zoomedImg.className = options.zoomImageProps.className)
zoomedImg.style.maxWidth = "none"
zoomedImg.style.position = "absolute"
zoomedImg.style.top = "0"
Expand Down
1 change: 1 addition & 0 deletions packages/docs/src/api/createZoomImageMove.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type ZoomImageMoveOptions = {
// Props for the zoomed image
zoomImageProps?: {
alt?: string
className?: string
}

// Zoom scale, default is 4
Expand Down
22 changes: 11 additions & 11 deletions size.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"@zoom-image/core": {
"createZoomImageWheel": "2.17 KB",
"createZoomImageHover": "1.28 KB",
"createZoomImageMove": "1 KB",
"createZoomImageMove": "1.02 KB",
"createZoomImageClick": "943 B",
"cropImage": "386 B",
"makeCalculateZoom": "171 B",
Expand All @@ -11,43 +11,43 @@
"@zoom-image/react": {
"useZoomImageWheel": "2.46 KB",
"useZoomImageHover": "1.56 KB",
"useZoomImageMove": "1.26 KB",
"useZoomImageMove": "1.28 KB",
"useZoomImageClick": "1.18 KB"
},
"@zoom-image/preact": {
"useZoomImageWheel": "3.33 KB",
"useZoomImageHover": "2.46 KB",
"useZoomImageMove": "2.19 KB",
"useZoomImageMove": "2.21 KB",
"useZoomImageClick": "2.11 KB"
},
"@zoom-image/qwik": {
"useZoomImageWheel": "2.58 KB",
"useZoomImageHover": "1.67 KB",
"useZoomImageMove": "1.37 KB",
"useZoomImageMove": "1.38 KB",
"useZoomImageClick": "1.29 KB"
},
"@zoom-image/solid": {
"useZoomImageWheel": "3.62 KB",
"useZoomImageHover": "2.75 KB",
"useZoomImageMove": "2.48 KB",
"useZoomImageMove": "2.49 KB",
"useZoomImageClick": "2.4 KB"
},
"@zoom-image/svelte": {
"useZoomImageWheel": "2.64 KB",
"useZoomImageHover": "1.75 KB",
"useZoomImageMove": "1.48 KB",
"useZoomImageMove": "1.49 KB",
"useZoomImageClick": "1.39 KB"
},
"@zoom-image/vue": {
"useZoomImageWheel": "2.42 KB",
"useZoomImageHover": "1.54 KB",
"useZoomImageMove": "1.25 KB",
"useZoomImageMove": "1.27 KB",
"useZoomImageClick": "1.17 KB"
},
"@zoom-image/angular": {
"ZoomImageClickService": "4.04 KB",
"ZoomImageHoverService": "4.04 KB",
"ZoomImageMoveService": "4.04 KB",
"ZoomImageWheelService": "4.04 KB"
"ZoomImageHoverService": "4.07 KB",
"ZoomImageClickService": "4.06 KB",
"ZoomImageMoveService": "4.06 KB",
"ZoomImageWheelService": "4.06 KB"
}
}

0 comments on commit 416a0be

Please sign in to comment.