Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: detached zoom should not be on by default #185

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading