Skip to content

Commit 2ec5c9e

Browse files
authored
Carousel: Fix bug when carousel slides contain list elements (#534)
* Use the `nav` element to query for child list items. * Store the pagination class name in a constant and use to select the pagination component. * Version bump to v14.3.16
1 parent 8e80b51 commit 2ec5c9e

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "honeycomb-web-toolkit",
3-
"version": "14.3.15",
3+
"version": "14.3.16",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/red-gate/honeycomb-web-toolkit"

src/carousel/js/honeycomb.carousel.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import loadScript from '../../document/js/honeycomb.document.load-script';
22

3+
const paginationClassName = 'carousel__pagination';
4+
35
const rearrangeNav = (carousel) => {
46
// selectors
5-
let nav = carousel.querySelector('ul');
7+
let nav = carousel.querySelector(`ul.${paginationClassName}`);
68
let leftButton = carousel.querySelector('.slick-prev');
79
let rightButton = carousel.querySelector('.slick-next');
810

@@ -21,7 +23,7 @@ const rearrangeNav = (carousel) => {
2123

2224
// the left button can't be the first element in the <ul>, otherwise it messes up the navigation, which counts <ul> child elements to map the slides to the links - adding a new first-child pushes the links off by one
2325
// so we need to add it to the end of the list, and translate its position by working out the width of the nav, plus the width of the arrow
24-
let navWidth = ( carousel.querySelectorAll('ul li').length - 1 ) * 30 + 130;
26+
let navWidth = ( nav.querySelectorAll('li').length - 1 ) * 30 + 130;
2527
leftButton.style.transform = `translate(-${navWidth}px, 0px)`;
2628

2729
} else if(!nav && leftButton && rightButton) {
@@ -67,7 +69,7 @@ const init = ( config = {} ) => {
6769
let carousel = carousels[ i ];
6870
let options = {
6971
autoplaySpeed: 4000,
70-
dotsClass: 'slick-dots carousel__pagination',
72+
dotsClass: `slick-dots ${paginationClassName}`,
7173
adaptiveHeight: false,
7274
dots: true
7375
};

0 commit comments

Comments
 (0)