@@ -10,6 +10,7 @@ import {
10
10
import EventProvider from "../EventProvider.js" ;
11
11
import UI5Element from "../UI5Element.js" ;
12
12
import NavigationMode from "../types/NavigationMode.js" ;
13
+ import ItemNavigationBehavior from "../types/ItemNavigationBehavior.js" ;
13
14
14
15
// navigatable items must have id and tabindex
15
16
class ItemNavigation extends EventProvider {
@@ -19,6 +20,7 @@ class ItemNavigation extends EventProvider {
19
20
this . currentIndex = options . currentIndex || 0 ;
20
21
this . rowSize = options . rowSize || 1 ;
21
22
this . cyclic = options . cyclic || false ;
23
+ this . behavior = options . behavior || ItemNavigationBehavior . Static ;
22
24
23
25
const navigationMode = options . navigationMode ;
24
26
const autoNavigation = ! navigationMode || navigationMode === NavigationMode . Auto ;
@@ -48,17 +50,24 @@ class ItemNavigation extends EventProvider {
48
50
49
51
_onKeyPress ( event ) {
50
52
const items = this . _getItems ( ) ;
51
-
52
53
if ( this . currentIndex >= items . length ) {
53
- if ( ! this . cyclic ) {
54
- this . currentIndex = items . length - 1 ;
54
+ if ( this . behavior !== ItemNavigationBehavior . Cyclic ) {
55
+ if ( this . behavior === ItemNavigationBehavior . Paging ) {
56
+ this . currentIndex = this . currentIndex - items . length ;
57
+ } else {
58
+ this . currentIndex = items . length - 1 ;
59
+ }
55
60
this . fireEvent ( ItemNavigation . BORDER_REACH , { start : false , end : true , offset : this . currentIndex } ) ;
56
61
} else {
57
62
this . currentIndex = this . currentIndex - items . length ;
58
63
}
59
64
} else if ( this . currentIndex < 0 ) {
60
- if ( ! this . cyclic ) {
61
- this . currentIndex = 0 ;
65
+ if ( this . behavior !== ItemNavigationBehavior . Cyclic ) {
66
+ if ( this . behavior === ItemNavigationBehavior . Paging ) {
67
+ this . currentIndex = items . length + this . currentIndex - this . rowSize + ( this . rowSize - ( this . _getItems ( ) . length % this . rowSize ) ) ;
68
+ } else {
69
+ this . currentIndex = 0 ;
70
+ }
62
71
this . fireEvent ( ItemNavigation . BORDER_REACH , { start : true , end : false , offset : this . currentIndex } ) ;
63
72
} else {
64
73
this . currentIndex = items . length + this . currentIndex ;
0 commit comments