Skip to content

Commit

Permalink
fix(hash-navigation): handle slide to none existing hash (#6681)
Browse files Browse the repository at this point in the history
* Also do an early return on a NaN value

* Update hash-navigation.js

---------

Co-authored-by: Vladimir Kharlampidi <[email protected]>
  • Loading branch information
jur-ng and nolimits4web authored May 15, 2023
1 parent 0fcd210 commit 7f3fa96
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/modules/hash-navigation/hash-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export default function HashNavigation({ swiper, extendParams, emit, on }) {
const activeSlideHash = activeSlideEl ? activeSlideEl.getAttribute('data-hash') : '';
if (newHash !== activeSlideHash) {
const newIndex = swiper.params.hashNavigation.getSlideIndex(swiper, newHash);
console.log(newIndex);
if (typeof newIndex === 'undefined') return;
if (typeof newIndex === 'undefined' || Number.isNaN(newIndex)) return;
swiper.slideTo(newIndex);
}
};
Expand Down

0 comments on commit 7f3fa96

Please sign in to comment.