Skip to content

Commit

Permalink
border-radius added - locked zoom when not on fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmanueldaza committed Dec 14, 2024
1 parent effe079 commit 7e8dfed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/components/Slideshow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ const Slideshow: React.FC = () => {
className={styles.imageWrapper}
style={{
transform: `scale(${scale})`,
cursor: isFullscreen ? "zoom-in" : "pointer", // Modify cursor based on fullscreen state
}}
onClick={toggleFullscreen}
>
Expand Down
9 changes: 5 additions & 4 deletions src/hooks/useSlideshow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const useSlideshow = (

const pauseSlideshow = useCallback(() => {
setIsPaused(true);
if (!isFullscreen) {
if (isFullscreen) {
setScale(baseScale);
}
}, [isFullscreen]);
Expand All @@ -48,16 +48,17 @@ export const useSlideshow = (

const handleWheel = useCallback(
(event: WheelEvent) => {
if (isPaused) {
if (isPaused && isFullscreen) {
// Add isFullscreen check here
event.preventDefault();
const delta = event.deltaY * -0.002;
setScale((prevScale) => {
const newScale = prevScale + delta;
return Math.min(Math.max(newScale, baseScale), maxScale); // Using maxScale here
return Math.min(Math.max(newScale, baseScale), maxScale);
});
}
},
[isPaused],
[isPaused, isFullscreen], // Add isFullscreen to dependencies
);

const handleTouchStart = useCallback(
Expand Down
9 changes: 7 additions & 2 deletions src/styles/Slideshow.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
width: 100%;
height: 100%;
cursor: zoom-in;
cursor: pointer; /* Default cursor */
}

.fullscreen .imageWrapper {
cursor: zoom-out;
cursor: zoom-in; /* Only show zoom cursor in fullscreen */
}

.fullscreen .imageWrapper[style*="scale"] {
cursor: zoom-out; /* Show zoom-out cursor when zoomed in fullscreen */
}

.loading {
Expand All @@ -71,6 +75,7 @@
.mainImage {
opacity: 0;
transition: opacity 0.3s ease;
border-radius: 20px;
}

.mainImage.loaded {
Expand Down

0 comments on commit 7e8dfed

Please sign in to comment.