Skip to content

Commit

Permalink
fix: detached zoom should not be on by default
Browse files Browse the repository at this point in the history
  • Loading branch information
cristinecula committed Dec 8, 2023
1 parent 41ca46c commit 798c6f4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
1 change: 1 addition & 0 deletions cosmoz-image-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ customElements.define(
'show-nav',
'show-page-number',
'show-zoom',
'detached-show-zoom',
'loop',
'title',
],
Expand Down
2 changes: 2 additions & 0 deletions lib/hooks/use-cosmoz-image-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const onImageError = (e) => {
title,
downloadFileName = 'archive',
loop,
detachedShowZoom,
} = host,
[isZoomed, setIsZoomed] = useState(false),
_onZoomChanged = (ev) => setIsZoomed(ev.detail.value > 1),
Expand All @@ -69,6 +70,7 @@ const onImageError = (e) => {
title,
loop,
syncImageIndex,
detachedShowZoom,
onDetach: () => setDetached(true),
onClose: () => setDetached(false),
}),
Expand Down
3 changes: 2 additions & 1 deletion lib/popout.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const popout = ({
syncImageIndex,
title,
loop,
detachedShowZoom,
onDetach,
onClose,
}) => {
Expand All @@ -37,7 +38,7 @@ export const popout = ({
.currentImageIndex=${index}
@current-image-index-changed=${syncImageIndex}
show-nav
show-zoom
?show-zoom=${detachedShowZoom}
show-close
?loop=${loop}
@close=${() => pout.close()}
Expand Down
46 changes: 34 additions & 12 deletions stories/cosmoz-image-viewer.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,48 @@ export default {
component: 'cosmoz-image-viewer',
};

export const Basic = () => html`
export const Basic = ({
showDetach,
showFullscreen,
showPageNumber,
showNav,
loop,
showZoom,
detachedShowZoom,
}) => html`
<cosmoz-image-viewer
show-detach
show-fullscreen
show-page-number
show-nav
loop
?show-detach=${showDetach}
?show-fullscreen=${showFullscreen}
?show-page-number=${showPageNumber}
?show-nav=${showNav}
?loop=${loop}
?show-zoom=${showZoom}
?detached-show-zoom=${detachedShowZoom}
.images=${images}
></cosmoz-image-viewer>
<cosmoz-image-viewer
show-detach
show-fullscreen
show-page-number
show-nav
loop
?show-detach=${showDetach}
?show-fullscreen=${showFullscreen}
?show-page-number=${showPageNumber}
?show-nav=${showNav}
?loop=${loop}
?show-zoom=${showZoom}
?detached-show-zoom=${detachedShowZoom}
.images=${['stories/images/cosmos1.jpg', 'stories/images/cosmos2.jpg']}
></cosmoz-image-viewer>
`;

Basic.args = {
showDetach: true,
showFullscreen: true,
showPageNumber: true,
showNav: true,
loop: true,
showZoom: false,
detachedShowZoom: false,
};

export const Issue21 = () => {
const images1 = [
'stories/images/stockholm.jpg',
Expand Down

0 comments on commit 798c6f4

Please sign in to comment.