File tree 4 files changed +44
-1
lines changed
4 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 1
1
import RenderScheduler from "../RenderScheduler.js" ;
2
+ import { fireDirectionChange } from "./directionChange.js" ;
2
3
3
4
/**
4
5
* Re-renders all RTL-aware UI5 Elements.
@@ -7,7 +8,9 @@ import RenderScheduler from "../RenderScheduler.js";
7
8
*
8
9
* @returns {Promise<void> }
9
10
*/
10
- const applyDirection = ( ) => {
11
+ const applyDirection = async ( ) => {
12
+ const listenersResults = fireDirectionChange ( ) ;
13
+ await Promise . all ( listenersResults ) ;
11
14
RenderScheduler . reRenderAllUI5Elements ( { rtlAware : true } ) ;
12
15
return RenderScheduler . whenFinished ( ) ;
13
16
} ;
Original file line number Diff line number Diff line change
1
+ import EventProvider from "../EventProvider.js" ;
2
+
3
+ const eventProvider = new EventProvider ( ) ;
4
+ const DIR_CHANGE = "directionChange" ;
5
+
6
+ /**
7
+ * Attach a callback that will be executed whenever the application calls the "applyDirection" function
8
+ * @public
9
+ * @param listener
10
+ */
11
+ const attachDirectionChange = listener => {
12
+ eventProvider . attachEvent ( DIR_CHANGE , listener ) ;
13
+ } ;
14
+
15
+ /**
16
+ * Detach a callback that was passed with "attachDirectionChange"
17
+ * @public
18
+ * @param listener
19
+ */
20
+ const detachDirectionChange = listener => {
21
+ eventProvider . detachEvent ( DIR_CHANGE , listener ) ;
22
+ } ;
23
+
24
+ const fireDirectionChange = ( ) => {
25
+ return eventProvider . fireEvent ( DIR_CHANGE ) ;
26
+ } ;
27
+
28
+ export {
29
+ attachDirectionChange ,
30
+ detachDirectionChange ,
31
+ fireDirectionChange ,
32
+ } ;
Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
107
107
import { getFirstDayOfWeek } from "@ui5/webcomponents-base/dist/config/FormatSettings.js" ;
108
108
import { getRegisteredNames as getIconNames } from "@ui5/webcomponents-base/dist/SVGIconRegistry.js" ;
109
109
import applyDirection from "@ui5/webcomponents-base/dist/locale/applyDirection.js" ;
110
+ import { attachDirectionChange } from "@ui5/webcomponents-base/dist/locale/directionChange.js" ;
110
111
import ResizeHandler from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js" ;
111
112
112
113
const testAssets = {
@@ -125,6 +126,7 @@ const testAssets = {
125
126
} ,
126
127
getLocaleData,
127
128
applyDirection,
129
+ attachDirectionChange,
128
130
ResizeHandler,
129
131
addCustomCSS,
130
132
attachThemeLoaded,
Original file line number Diff line number Diff line change 78
78
< ui5-date-picker > </ ui5-date-picker >
79
79
< script >
80
80
81
+ setTimeout ( function ( ) {
82
+ window [ 'sap-ui-webcomponents-bundle' ] . attachDirectionChange ( function ( ) {
83
+ console . log ( "Direction changed" ) ;
84
+ } ) ;
85
+ } , 1000 ) ;
86
+
81
87
// Utility function to change RTL and apply the changes
82
88
function setDir ( dir ) {
83
89
document . body . dir = dir ;
You can’t perform that action at this time.
0 commit comments