From e7c007d5bfa8aba7a96271c34507212a0f8557f9 Mon Sep 17 00:00:00 2001 From: Simon Mayerhofer Date: Thu, 3 Oct 2019 12:50:07 +0200 Subject: [PATCH 1/2] Add options to change prev & next button aria labels --- README.md | 6 ++++++ js/flickity.js | 4 +++- js/prev-next-button.js | 5 ++++- test/index.html | 6 ++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 76de7cac..cca006aa 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,9 @@ var flky = new Flickity( '.gallery', { // set img data-flickity-lazyload="src.jpg" // set to number to load images adjacent cells + nextButtonAriaLabel: 'Next', + // sets next button aria-label + percentPosition: true, // sets positioning in percent values, rather than pixels // Enable if items have percent widths @@ -122,6 +125,9 @@ var flky = new Flickity( '.gallery', { prevNextButtons: true, // creates and enables buttons to click to previous & next cells + prevButtonAriaLabel: 'Previous', + // sets previous button aria-label + pageDots: true, // create and enable page dots diff --git a/js/flickity.js b/js/flickity.js index d06387be..39d9ba9c 100644 --- a/js/flickity.js +++ b/js/flickity.js @@ -105,9 +105,11 @@ Flickity.defaults = { percentPosition: true, resize: true, selectedAttraction: 0.025, - setGallerySize: true + setGallerySize: true, // watchCSS: false, // wrapAround: false + prevButtonAriaLabel: 'Previous', + nextButtonAriaLabel: 'Next', }; // hash of methods triggered on _create() diff --git a/js/prev-next-button.js b/js/prev-next-button.js index 058eef1d..f816551b 100644 --- a/js/prev-next-button.js +++ b/js/prev-next-button.js @@ -59,7 +59,10 @@ PrevNextButton.prototype._create = function() { // init as disabled this.disable(); - element.setAttribute( 'aria-label', this.isPrevious ? 'Previous' : 'Next' ); + var prevButtonAriaLabel = this.parent.options.prevButtonAriaLabel; + var nextButtonAriaLabel = this.parent.options.nextButtonAriaLabel; + + element.setAttribute( 'aria-label', this.isPrevious ? prevButtonAriaLabel : nextButtonAriaLabel ); // create arrow var svg = this.createSVG(); diff --git a/test/index.html b/test/index.html index 8e6a9160..48004c01 100644 --- a/test/index.html +++ b/test/index.html @@ -36,6 +36,12 @@ + + + From f31b6d9d2ff7b46980ce1d0c84146c098cbf8899 Mon Sep 17 00:00:00 2001 From: Simon Mayerhofer Date: Thu, 3 Oct 2019 12:57:50 +0200 Subject: [PATCH 2/2] Remove trailing comma to fit code style --- js/flickity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/flickity.js b/js/flickity.js index 39d9ba9c..4bdcef10 100644 --- a/js/flickity.js +++ b/js/flickity.js @@ -109,7 +109,7 @@ Flickity.defaults = { // watchCSS: false, // wrapAround: false prevButtonAriaLabel: 'Previous', - nextButtonAriaLabel: 'Next', + nextButtonAriaLabel: 'Next' }; // hash of methods triggered on _create()