瀏覽代碼

Support keyboard control in vertical mode.

NaotoshiFujita 5 年之前
父節點
當前提交
90ef946367
共有 4 個文件被更改,包括 20 次插入9 次删除
  1. 1 1
      dist/js/splide.min.js
  2. 二進制
      dist/js/splide.min.js.gz
  3. 1 1
      package.json
  4. 18 7
      src/js/components/keyboard/index.js

File diff suppressed because it is too large
+ 1 - 1
dist/js/splide.min.js


二進制
dist/js/splide.min.js.gz


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "@splidejs/splide",
-  "version": "1.0.17",
+  "version": "1.0.18",
   "description": "Splide is a lightweight and powerful slider without any dependencies.",
   "author": "Naotoshi Fujita",
   "license": "MIT",

+ 18 - 7
src/js/components/keyboard/index.js

@@ -13,11 +13,20 @@ import { subscribe } from "../../utils/dom";
  * @type {Object}
  */
 const KEY_MAP = {
-	ArrowLeft : '<',
-	ArrowRight: '>',
-	// For IE.
-	Left : '<',
-	Right: '>',
+	horizontal: {
+		ArrowLeft : '<',
+		ArrowRight: '>',
+		// For IE.
+		Left : '<',
+		Right: '>',
+	},
+	vertical: {
+		ArrowUp  : '<',
+		ArrowDown: '>',
+		// For IE.
+		Up  : '<',
+		Down: '>',
+	},
 };
 
 
@@ -41,6 +50,8 @@ export default ( Splide ) => {
 		 * Called when the component is mounted.
 		 */
 		mount() {
+			const map = KEY_MAP[ Splide.options.direction === 'ttb' ? 'vertical' : 'horizontal' ];
+
 			Splide.on( 'mounted updated', () => {
 				if ( removers ) {
 					removers[ 0 ]();
@@ -49,8 +60,8 @@ export default ( Splide ) => {
 
 				if ( Splide.options.keyboard ) {
 					removers = subscribe( Splide.root, 'keydown', e => {
-						if ( KEY_MAP[ e.key ] ) {
-							Splide.go( KEY_MAP[ e.key ] );
+						if ( map[ e.key ] ) {
+							Splide.go( map[ e.key ] );
 						}
 					} );
 				}

Some files were not shown because too many files changed in this diff