@@ -87,8 +87,8 @@ export const DrawerPanelContent: React.FunctionComponent<DrawerPanelContentProps
8787 const previouslyFocusedElement = React . useRef ( null ) ;
8888 let currWidth : number = 0 ;
8989 let panelRect : DOMRect ;
90- let right : number ;
91- let left : number ;
90+ let end : number ;
91+ let start : number ;
9292 let bottom : number ;
9393 let setInitialVals : boolean = true ;
9494
@@ -108,23 +108,52 @@ export const DrawerPanelContent: React.FunctionComponent<DrawerPanelContentProps
108108 const calcValueNow = ( ) => {
109109 let splitterPos ;
110110 let drawerSize ;
111+ const isRTL = window . getComputedStyle ( panel . current ) . getPropertyValue ( 'direction' ) === 'rtl' ;
111112
112- if ( isInline && position === 'right' ) {
113- splitterPos = panel . current . getBoundingClientRect ( ) . right - splitterRef . current . getBoundingClientRect ( ) . left ;
114- drawerSize = drawerRef . current . getBoundingClientRect ( ) . right - drawerRef . current . getBoundingClientRect ( ) . left ;
115- } else if ( isInline && position === 'left' ) {
116- splitterPos = splitterRef . current . getBoundingClientRect ( ) . right - panel . current . getBoundingClientRect ( ) . left ;
117- drawerSize = drawerRef . current . getBoundingClientRect ( ) . right - drawerRef . current . getBoundingClientRect ( ) . left ;
118- } else if ( position === 'right' ) {
119- splitterPos =
120- drawerContentRef . current . getBoundingClientRect ( ) . right - splitterRef . current . getBoundingClientRect ( ) . left ;
121- drawerSize =
122- drawerContentRef . current . getBoundingClientRect ( ) . right - drawerContentRef . current . getBoundingClientRect ( ) . left ;
123- } else if ( position === 'left' ) {
124- splitterPos =
125- splitterRef . current . getBoundingClientRect ( ) . right - drawerContentRef . current . getBoundingClientRect ( ) . left ;
126- drawerSize =
127- drawerContentRef . current . getBoundingClientRect ( ) . right - drawerContentRef . current . getBoundingClientRect ( ) . left ;
113+ if ( isInline && ( position === 'end' || position === 'right' ) ) {
114+ if ( isRTL ) {
115+ splitterPos = panel . current . getBoundingClientRect ( ) . left - splitterRef . current . getBoundingClientRect ( ) . right ;
116+ drawerSize = drawerRef . current . getBoundingClientRect ( ) . left - drawerRef . current . getBoundingClientRect ( ) . right ;
117+ } else {
118+ splitterPos = panel . current . getBoundingClientRect ( ) . right - splitterRef . current . getBoundingClientRect ( ) . left ;
119+ drawerSize = drawerRef . current . getBoundingClientRect ( ) . right - drawerRef . current . getBoundingClientRect ( ) . left ;
120+ }
121+ } else if ( isInline && ( position === 'start' || position === 'left' ) ) {
122+ if ( isRTL ) {
123+ splitterPos = splitterRef . current . getBoundingClientRect ( ) . left - panel . current . getBoundingClientRect ( ) . right ;
124+ drawerSize = drawerRef . current . getBoundingClientRect ( ) . left - drawerRef . current . getBoundingClientRect ( ) . right ;
125+ } else {
126+ splitterPos = splitterRef . current . getBoundingClientRect ( ) . right - panel . current . getBoundingClientRect ( ) . left ;
127+ drawerSize = drawerRef . current . getBoundingClientRect ( ) . right - drawerRef . current . getBoundingClientRect ( ) . left ;
128+ }
129+ } else if ( position === 'end' || position === 'right' ) {
130+ if ( isRTL ) {
131+ splitterPos =
132+ drawerContentRef . current . getBoundingClientRect ( ) . left - splitterRef . current . getBoundingClientRect ( ) . right ;
133+ drawerSize =
134+ drawerContentRef . current . getBoundingClientRect ( ) . left -
135+ drawerContentRef . current . getBoundingClientRect ( ) . right ;
136+ } else {
137+ splitterPos =
138+ drawerContentRef . current . getBoundingClientRect ( ) . right - splitterRef . current . getBoundingClientRect ( ) . left ;
139+ drawerSize =
140+ drawerContentRef . current . getBoundingClientRect ( ) . right -
141+ drawerContentRef . current . getBoundingClientRect ( ) . left ;
142+ }
143+ } else if ( position === 'start' || position === 'left' ) {
144+ if ( isRTL ) {
145+ splitterPos =
146+ splitterRef . current . getBoundingClientRect ( ) . left - drawerContentRef . current . getBoundingClientRect ( ) . right ;
147+ drawerSize =
148+ drawerContentRef . current . getBoundingClientRect ( ) . left -
149+ drawerContentRef . current . getBoundingClientRect ( ) . right ;
150+ } else {
151+ splitterPos =
152+ splitterRef . current . getBoundingClientRect ( ) . right - drawerContentRef . current . getBoundingClientRect ( ) . left ;
153+ drawerSize =
154+ drawerContentRef . current . getBoundingClientRect ( ) . right -
155+ drawerContentRef . current . getBoundingClientRect ( ) . left ;
156+ }
128157 } else if ( position === 'bottom' ) {
129158 splitterPos =
130159 drawerContentRef . current . getBoundingClientRect ( ) . bottom - splitterRef . current . getBoundingClientRect ( ) . top ;
@@ -166,24 +195,31 @@ export const DrawerPanelContent: React.FunctionComponent<DrawerPanelContentProps
166195 } ;
167196
168197 const handleControlMove = ( e : MouseEvent | TouchEvent , controlPosition : number ) => {
198+ const isRTL = window . getComputedStyle ( panel . current ) . getPropertyValue ( 'direction' ) === 'rtl' ;
199+
169200 e . stopPropagation ( ) ;
170201 if ( ! isResizing ) {
171202 return ;
172203 }
173204
174205 if ( setInitialVals ) {
175206 panelRect = panel . current . getBoundingClientRect ( ) ;
176- right = panelRect . right ;
177- left = panelRect . left ;
207+ if ( isRTL ) {
208+ start = panelRect . right ;
209+ end = panelRect . left ;
210+ } else {
211+ end = panelRect . right ;
212+ start = panelRect . left ;
213+ }
178214 bottom = panelRect . bottom ;
179215 setInitialVals = false ;
180216 }
181217 const mousePos = controlPosition ;
182218 let newSize = 0 ;
183- if ( position === 'right' ) {
184- newSize = right - mousePos ;
185- } else if ( position === 'left' ) {
186- newSize = mousePos - left ;
219+ if ( position === 'end' || position === ' right') {
220+ newSize = isRTL ? mousePos - end : end - mousePos ;
221+ } else if ( position === 'start' || position === ' left') {
222+ newSize = isRTL ? start - mousePos : mousePos - start ;
187223 } else {
188224 newSize = bottom - mousePos ;
189225 }
@@ -225,6 +261,8 @@ export const DrawerPanelContent: React.FunctionComponent<DrawerPanelContentProps
225261 const callbackMouseUp = React . useCallback ( handleMouseup , [ ] ) ;
226262
227263 const handleKeys = ( e : React . KeyboardEvent ) => {
264+ const isRTL = window . getComputedStyle ( panel . current ) . getPropertyValue ( 'direction' ) === 'rtl' ;
265+
228266 const key = e . key ;
229267 if (
230268 key !== 'Escape' &&
@@ -248,9 +286,17 @@ export const DrawerPanelContent: React.FunctionComponent<DrawerPanelContentProps
248286 newSize = position === 'bottom' ? panelRect . height : panelRect . width ;
249287 let delta = 0 ;
250288 if ( key === 'ArrowRight' ) {
251- delta = position === 'left' ? increment : - increment ;
289+ if ( isRTL ) {
290+ delta = position === 'left' || position === 'start' ? - increment : increment ;
291+ } else {
292+ delta = position === 'left' || position === 'start' ? increment : - increment ;
293+ }
252294 } else if ( key === 'ArrowLeft' ) {
253- delta = position === 'left' ? - increment : increment ;
295+ if ( isRTL ) {
296+ delta = position === 'left' || position === 'start' ? increment : - increment ;
297+ } else {
298+ delta = position === 'left' || position === 'start' ? - increment : increment ;
299+ }
254300 } else if ( key === 'ArrowUp' ) {
255301 delta = increment ;
256302 } else if ( key === 'ArrowDown' ) {
0 commit comments