Skip to content

Commit

Permalink
Merge pull request #2143 from tf/hotspots-7
Browse files Browse the repository at this point in the history
Further improvements for hotspots element
  • Loading branch information
tf authored Aug 9, 2024
2 parents 28d7035 + 2a57537 commit 96fb09b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion entry_types/scrolled/package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"react_ujs": "^2.6.1",
"reselect": "^4.0.0",
"screenfull": "^5.1.0",
"scroll-timeline": "https://github.com/tf/scroll-timeline#pageflow-scrolled-1",
"scroll-timeline": "https://github.com/tf/scroll-timeline#pageflow-scrolled-2",
"slate": "^0.57.3",
"slate-react": "^0.57.3",
"slugify": "^1.4.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,20 @@ export function HotspotsImage({
<div className={styles.left}>
<ScrollButton direction="left"
disabled={activeIndex === -1}
onClick={() => activateArea(activeIndex - 1)} />
onClick={() => {
if (activeIndex >= 0) {
activateArea(activeIndex - 1)
}
}} />
</div>
<div className={styles.right}>
<ScrollButton direction="right"
disabled={activeIndex >= areas.length}
onClick={() => activateArea(activeIndex + 1)}/>
onClick={() => {
if (activeIndex < areas.length) {
activateArea(activeIndex + 1)
}
}}/>
</div>
</>
);
Expand Down Expand Up @@ -185,7 +193,9 @@ export function HotspotsImage({
<Area key={index}
area={area}
portraitMode={portraitMode}
noPointerEvents={panZoomEnabled && activeIndex >= 0}
noPointerEvents={panZoomEnabled &&
activeIndex >= 0 &&
activeIndex < areas.length}
onMouseEnter={() => setHoveredIndex(index)}
onMouseLeave={() => setHoveredIndex(-1)}
onClick={() => {
Expand All @@ -200,7 +210,10 @@ export function HotspotsImage({
return areas.map((area, index) =>
<Indicator key={index}
area={area}
hidden={panZoomEnabled && activeIndex >= 0 && activeIndex !== index}
hidden={panZoomEnabled &&
activeIndex >= 0 &&
activeIndex < areas.length &&
activeIndex !== index}
outerRef={setIndicatorRef(index)}
portraitMode={portraitMode} />
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export function useScrollPanZoom({

scroller.scrollTo(Math.abs(scroller.offsetLeft - step.offsetLeft), 0);

if (!steps) {
return;
}

wrapperRef.current.animate(
[
keyframe(steps[from + 1]),
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11529,9 +11529,9 @@ scroll-into-view-if-needed@^2.2.20:
dependencies:
compute-scroll-into-view "^1.0.13"

"scroll-timeline@https://github.com/tf/scroll-timeline#pageflow-scrolled-1":
"scroll-timeline@https://github.com/tf/scroll-timeline#pageflow-scrolled-2":
version "1.0.0"
resolved "https://github.com/tf/scroll-timeline#c47ac20bc7dfabc2f9bc6f31a95b0e4c662fdffe"
resolved "https://github.com/tf/scroll-timeline#3613d3acd8ae628f523349c6c7c79474ceb13862"

"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.1:
version "5.7.2"
Expand Down

0 comments on commit 96fb09b

Please sign in to comment.