-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement spatial navigation #8570
Changes from 1 commit
bdb7e1c
b2bb855
d7c4ba7
55130bb
750c72e
359e6cf
e1e3a59
60a2d5e
b2f4c51
3a99013
7e180a8
713ac98
f96e649
f81bcfc
1232d27
241bf09
e2008da
6118b1c
014d6eb
1966c3e
2289953
5b8b08d
e8e1dfd
0745420
c54953a
2bb76c3
00ac57f
ad6ef57
72b8d8b
a6208eb
bc6ca03
47612fc
6ba35db
ba994a4
4011fb5
a96bf43
ed074cc
0202a36
0827c84
498edc7
b701a95
b411f1f
d7e8cf2
4127413
b5c047a
5ee3ba0
96a5ee9
25ec8dc
5399c35
893e2d7
7bc5a83
6868c87
861d8e5
f74156d
f3eb1cf
31c7f1f
47b7e14
02e3411
4f4b83f
9b7cd97
3ee07c7
45e5748
8aba907
67d9dd1
23c4533
08a51b9
2479c27
5538a20
2d7df4a
1780f8a
c8e02ad
8d0701e
05f3008
0f6a160
87fd178
3552329
1972d46
ddd5b12
df799f7
f88ba6e
e8580e9
3ff768d
deddd0a
1d84062
88d66ce
b7f8807
c741e8a
51b0e32
825e7a2
af22e40
c310238
05a98db
004db79
23c98f1
ce0683b
caf1142
147256b
4fb37ed
46b7e24
01afc9d
4db8df4
015a537
a574f1b
68f98f6
4fa895f
41e5f1b
00a8c4c
3170a42
20814f7
cc2afe0
91a779c
927138f
4df8344
00e8677
5d972bc
750acdb
361617c
d394389
7a7a11b
69e7c4f
b33f051
829da01
b8388ef
9604387
55f8987
27c480b
34224c8
1b8f08e
96fccee
cca5423
3f27e14
7a9e843
4cc49c6
0e32e50
396fd4f
6661205
47fa98c
c9249a1
c8e8d60
fd8a355
dada396
c89b7cd
e4b6ae2
e38dd44
a53b7b4
19f6606
ad25ea0
791bdf1
72e3d07
6f99e69
0f32adb
76827b1
010c402
36fb9b5
351fe23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
… class Modify SpatialNavigation class: -Add ‘lastFocusedComponent’ -Add function ‘refocusComponent’ Modify ModalDialog class: -Add condition on ‘close’ function Modify Component class: -Modify ‘handleBlur’ to store blurred component
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ class SpatialNavigation { | |
this.isPaused = false; | ||
this.onKeyDown = this.onKeyDown.bind(this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. private There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in the latest commit |
||
this.currentFocus = initialFocusedComponent || null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. private There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed in the latest commit as it wasn't used. |
||
this.lastFocusedComponent = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. private There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in the latest commit |
||
} | ||
|
||
/** | ||
|
@@ -88,8 +89,12 @@ class SpatialNavigation { | |
* Handles Player Blur. | ||
* | ||
*/ | ||
handlePlayerBlur() { | ||
handlePlayerBlur(component) { | ||
this.pause(); | ||
|
||
if (component && component.el_) { | ||
this.lastFocusedComponent = component; | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -264,6 +269,23 @@ class SpatialNavigation { | |
} | ||
} | ||
|
||
/** | ||
* Focus last focused component saved before blur on player. | ||
*/ | ||
refocusComponent() { | ||
if (this.lastFocusedComponent) { | ||
this.getComponents(); | ||
|
||
for (let i = 0; i < this.focusableComponents.length; i++) { | ||
if (this.focusableComponents[i].name_ === this.lastFocusedComponent.name_) { | ||
this.focusableComponents[i].focus(); | ||
} | ||
} | ||
} else { | ||
this.getComponents()[0].focus(); | ||
} | ||
} | ||
|
||
/** | ||
* Calculates the distance between two points, adjusting the calculation based on | ||
* the specified navigation direction. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in the latest commit