Skip to content

Commit 7336491

Browse files
committed
fix: legacy app navigation snapper on RTL layout
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 32264c7 commit 7336491

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

core/css/mobile.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626

2727
/* APP SIDEBAR TOGGLE and SWIPE ----------------------------------------------*/
2828
#app-navigation:not(.vue) {
29-
transform: translateX(-#{variables.$navigation-width});
3029
position: fixed;
3130
height: var(--body-height);
31+
transform: translateX(-#{variables.$navigation-width});
3232
}
33-
.snapjs-left {
33+
.snapjs-left,
34+
.snapjs-right {
3435
#app-navigation {
3536
transform: translateX(0);
3637
}

core/src/init.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import $ from 'jquery'
99
import moment from 'moment'
1010

1111
import OC from './OC/index.js'
12+
import { isRTL } from '@nextcloud/l10n'
1213
import { initSessionHeartBeat } from './session-heartbeat.ts'
1314
import { setUp as setUpContactsMenu } from './components/ContactsMenu.js'
1415
import { setUp as setUpMainMenu } from './components/MainMenu.js'
@@ -58,6 +59,9 @@ moment.locale(locale)
5859
* Initializes core
5960
*/
6061
export const initCore = () => {
62+
const SNAPPER_OPEN = isRTL() ? 'right' : 'left'
63+
const SNAPPER_CLOSE = isRTL() ? 'left' : 'right'
64+
6165
interceptRequests()
6266
initFallbackClipboardAPI()
6367

@@ -116,7 +120,7 @@ export const initCore = () => {
116120
// App sidebar on mobile
117121
const snapper = new Snap({
118122
element: document.getElementById('app-content'),
119-
disable: 'right',
123+
disable: SNAPPER_CLOSE,
120124
maxPosition: 300, // $navigation-width
121125
minDragDistance: 100,
122126
})
@@ -162,7 +166,7 @@ export const initCore = () => {
162166
if (animating || snapper.state().state !== 'closed') {
163167
return
164168
}
165-
oldSnapperOpen('left')
169+
oldSnapperOpen(SNAPPER_OPEN)
166170
}
167171

168172
const _snapperClose = () => {
@@ -187,16 +191,17 @@ export const initCore = () => {
187191
}
188192

189193
$('#app-navigation-toggle').click((e) => {
194+
console.error('snapper', SNAPPER_OPEN, isRTL(), snapper.state().state, snapper)
190195
// close is implicit in the button by snap.js
191-
if (snapper.state().state !== 'left') {
192-
snapper.open()
196+
if (snapper.state().state !== SNAPPER_OPEN) {
197+
snapper.open(SNAPPER_OPEN)
193198
}
194199
})
195200
$('#app-navigation-toggle').keypress(e => {
196-
if (snapper.state().state === 'left') {
201+
if (snapper.state().state === SNAPPER_OPEN) {
197202
snapper.close()
198203
} else {
199-
snapper.open()
204+
snapper.open(SNAPPER_OPEN)
200205
}
201206
})
202207

0 commit comments

Comments
 (0)