|
@@ -1,6 +1,6 @@
|
|
|
/*!
|
|
|
* Splide.js
|
|
|
- * Version : 2.4.1
|
|
|
+ * Version : 2.4.2
|
|
|
* License : MIT
|
|
|
* Copyright: 2020 Naotoshi Fujita
|
|
|
*/
|
|
@@ -1292,11 +1292,14 @@ var DEFAULTS = {
|
|
|
easing: 'cubic-bezier(.42,.65,.27,.99)',
|
|
|
|
|
|
/**
|
|
|
- * Whether to control a slide via keyboard.
|
|
|
+ * Whether to enable keyboard shortcuts
|
|
|
+ * - true or 'global': Listen to keydown event of the document.
|
|
|
+ * - 'focused': Listen to the keydown event of the slider root element. tabindex="0" will be added to the element.
|
|
|
+ * - false: Disable keyboard shortcuts.
|
|
|
*
|
|
|
- * @type {boolean}
|
|
|
+ * @type {boolean|string}
|
|
|
*/
|
|
|
- keyboard: true,
|
|
|
+ keyboard: 'global',
|
|
|
|
|
|
/**
|
|
|
* Whether to allow mouse drag and touch swipe.
|
|
@@ -1370,6 +1373,13 @@ var DEFAULTS = {
|
|
|
*/
|
|
|
accessibility: true,
|
|
|
|
|
|
+ /**
|
|
|
+ * Whether to add tabindex="0" to visible slides or not.
|
|
|
+ *
|
|
|
+ * @type {boolean}
|
|
|
+ */
|
|
|
+ slideFocus: true,
|
|
|
+
|
|
|
/**
|
|
|
* Determine if a slider is navigation for another.
|
|
|
* Use "sync" API to synchronize two sliders.
|
|
@@ -4990,6 +5000,55 @@ var SRC_DATA_NAME = 'data-splide-lazy';
|
|
|
|
|
|
return Lazyload;
|
|
|
});
|
|
|
+// CONCATENATED MODULE: ./src/js/constants/a11y.js
|
|
|
+/**
|
|
|
+ * Export aria attribute names.
|
|
|
+ *
|
|
|
+ * @author Naotoshi Fujita
|
|
|
+ * @copyright Naotoshi Fujita. All rights reserved.
|
|
|
+ */
|
|
|
+
|
|
|
+/**
|
|
|
+ * Attribute name for aria-current.
|
|
|
+ *
|
|
|
+ * @type {string}
|
|
|
+ */
|
|
|
+var ARIA_CURRENRT = 'aria-current';
|
|
|
+/**
|
|
|
+ * Attribute name for aria-control.
|
|
|
+ *
|
|
|
+ * @type {string}
|
|
|
+ */
|
|
|
+
|
|
|
+var ARIA_CONTROLS = 'aria-controls';
|
|
|
+/**
|
|
|
+ * Attribute name for aria-control.
|
|
|
+ *
|
|
|
+ * @type {string}
|
|
|
+ */
|
|
|
+
|
|
|
+var ARIA_LABEL = 'aria-label';
|
|
|
+/**
|
|
|
+ * Attribute name for aria-labelledby.
|
|
|
+ *
|
|
|
+ * @type {string}
|
|
|
+ */
|
|
|
+
|
|
|
+var ARIA_LABELLEDBY = 'aria-labelledby';
|
|
|
+/**
|
|
|
+ * Attribute name for aria-hidden.
|
|
|
+ *
|
|
|
+ * @type {string}
|
|
|
+ */
|
|
|
+
|
|
|
+var ARIA_HIDDEN = 'aria-hidden';
|
|
|
+/**
|
|
|
+ * Attribute name for tab-index.
|
|
|
+ *
|
|
|
+ * @type {string}
|
|
|
+ */
|
|
|
+
|
|
|
+var TAB_INDEX = 'tabindex';
|
|
|
// CONCATENATED MODULE: ./src/js/components/keyboard/index.js
|
|
|
/**
|
|
|
* The component for controlling slides via keyboard.
|
|
@@ -4998,11 +5057,13 @@ var SRC_DATA_NAME = 'data-splide-lazy';
|
|
|
* @copyright Naotoshi Fujita. All rights reserved.
|
|
|
*/
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* Map a key to a slide control.
|
|
|
*
|
|
|
* @type {Object}
|
|
|
*/
|
|
|
+
|
|
|
var KEY_MAP = {
|
|
|
ltr: {
|
|
|
ArrowLeft: '<',
|
|
@@ -5034,82 +5095,47 @@ var KEY_MAP = {
|
|
|
* @return {Object} - The component object.
|
|
|
*/
|
|
|
|
|
|
-/* harmony default export */ var keyboard = (function (Splide) {
|
|
|
+/* harmony default export */ var components_keyboard = (function (Splide) {
|
|
|
/**
|
|
|
- * Hold the root element.
|
|
|
+ * Hold the target element.
|
|
|
*
|
|
|
- * @type {Element}
|
|
|
+ * @type {Element|Document|undefined}
|
|
|
*/
|
|
|
- var root = Splide.root;
|
|
|
+ var target;
|
|
|
return {
|
|
|
/**
|
|
|
* Called when the component is mounted.
|
|
|
*/
|
|
|
mount: function mount() {
|
|
|
- var map = KEY_MAP[Splide.options.direction];
|
|
|
Splide.on('mounted updated', function () {
|
|
|
- Splide.off('keydown', root);
|
|
|
+ var options = Splide.options;
|
|
|
+ var root = Splide.root;
|
|
|
+ var map = KEY_MAP[options.direction];
|
|
|
+ var keyboard = options.keyboard;
|
|
|
+
|
|
|
+ if (target) {
|
|
|
+ Splide.off('keydown', target);
|
|
|
+ removeAttribute(root, TAB_INDEX);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (keyboard) {
|
|
|
+ if (keyboard === 'focused') {
|
|
|
+ target = root;
|
|
|
+ setAttribute(root, TAB_INDEX, 0);
|
|
|
+ } else {
|
|
|
+ target = document;
|
|
|
+ }
|
|
|
|
|
|
- if (Splide.options.keyboard) {
|
|
|
Splide.on('keydown', function (e) {
|
|
|
if (map[e.key]) {
|
|
|
Splide.go(map[e.key]);
|
|
|
}
|
|
|
- }, root);
|
|
|
+ }, target);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
});
|
|
|
-// CONCATENATED MODULE: ./src/js/constants/a11y.js
|
|
|
-/**
|
|
|
- * Export aria attribute names.
|
|
|
- *
|
|
|
- * @author Naotoshi Fujita
|
|
|
- * @copyright Naotoshi Fujita. All rights reserved.
|
|
|
- */
|
|
|
-
|
|
|
-/**
|
|
|
- * Attribute name for aria-current.
|
|
|
- *
|
|
|
- * @type {string}
|
|
|
- */
|
|
|
-var ARIA_CURRENRT = 'aria-current';
|
|
|
-/**
|
|
|
- * Attribute name for aria-control.
|
|
|
- *
|
|
|
- * @type {string}
|
|
|
- */
|
|
|
-
|
|
|
-var ARIA_CONTROLS = 'aria-controls';
|
|
|
-/**
|
|
|
- * Attribute name for aria-control.
|
|
|
- *
|
|
|
- * @type {string}
|
|
|
- */
|
|
|
-
|
|
|
-var ARIA_LABEL = 'aria-label';
|
|
|
-/**
|
|
|
- * Attribute name for aria-labelledby.
|
|
|
- *
|
|
|
- * @type {string}
|
|
|
- */
|
|
|
-
|
|
|
-var ARIA_LABELLEDBY = 'aria-labelledby';
|
|
|
-/**
|
|
|
- * Attribute name for aria-hidden.
|
|
|
- *
|
|
|
- * @type {string}
|
|
|
- */
|
|
|
-
|
|
|
-var ARIA_HIDDEN = 'aria-hidden';
|
|
|
-/**
|
|
|
- * Attribute name for tab-index.
|
|
|
- *
|
|
|
- * @type {string}
|
|
|
- */
|
|
|
-
|
|
|
-var TAB_INDEX = 'tabindex';
|
|
|
// CONCATENATED MODULE: ./src/js/components/a11y/index.js
|
|
|
/**
|
|
|
* The component for enhancing accessibility.
|
|
@@ -5205,7 +5231,10 @@ var TAB_INDEX = 'tabindex';
|
|
|
|
|
|
function updateSlide(slide, visible) {
|
|
|
setAttribute(slide, ARIA_HIDDEN, !visible);
|
|
|
- setAttribute(slide, TAB_INDEX, visible ? 0 : -1);
|
|
|
+
|
|
|
+ if (Splide.options.slideFocus) {
|
|
|
+ setAttribute(slide, TAB_INDEX, visible ? 0 : -1);
|
|
|
+ }
|
|
|
}
|
|
|
/**
|
|
|
* Initialize arrows if they are available.
|
|
@@ -5703,7 +5732,7 @@ var COMPLETE = {
|
|
|
Arrows: components_arrows,
|
|
|
Pagination: components_pagination,
|
|
|
LazyLoad: lazyload,
|
|
|
- Keyboard: keyboard,
|
|
|
+ Keyboard: components_keyboard,
|
|
|
Sync: sync,
|
|
|
A11y: a11y
|
|
|
};
|