Skip to content

Commit aa10162

Browse files
committed
feat(QDrawer): New Boolean prop (no-swipe-backdrop) quasarframework#5150
1 parent e0b59c1 commit aa10162

File tree

2 files changed

+42
-23
lines changed

2 files changed

+42
-23
lines changed

ui/src/components/layout/QDrawer.js

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ import slot from '../../utils/slot.js'
99

1010
const duration = 150
1111

12+
const directiveTemplate = {
13+
name: 'touch-pan',
14+
modifiers: {
15+
horizontal: true,
16+
mouse: true,
17+
mouseAllDir: true
18+
}
19+
}
20+
1221
export default Vue.extend({
1322
name: 'QDrawer',
1423

@@ -65,7 +74,8 @@ export default Vue.extend({
6574
overlay: Boolean,
6675
persistent: Boolean,
6776
noSwipeOpen: Boolean,
68-
noSwipeClose: Boolean
77+
noSwipeClose: Boolean,
78+
noSwipeBackdrop: Boolean
6979
},
7080

7181
data () {
@@ -289,6 +299,24 @@ export default Vue.extend({
289299
hideOnRouteChange () {
290300
return this.persistent !== true &&
291301
(this.belowBreakpoint === true || this.onScreenOverlay === true)
302+
},
303+
304+
openDirective () {
305+
if (this.belowBreakpoint === true) {
306+
return [{
307+
...directiveTemplate,
308+
value: this.__openByTouch
309+
}]
310+
}
311+
},
312+
313+
closeDirective () {
314+
if (this.belowBreakpoint === true) {
315+
return [{
316+
...directiveTemplate,
317+
value: this.__closeByTouch
318+
}]
319+
}
292320
}
293321
},
294322

@@ -550,29 +578,11 @@ export default Vue.extend({
550578
},
551579

552580
render (h) {
553-
const directives = [{
554-
name: 'touch-pan',
555-
modifiers: {
556-
horizontal: true,
557-
mouse: true,
558-
mouseAllDir: true
559-
},
560-
value: this.__closeByTouch
561-
}]
562-
563581
const child = [
564582
this.noSwipeOpen !== true && this.belowBreakpoint === true
565583
? h('div', {
566584
staticClass: `q-drawer__opener fixed-${this.side}`,
567-
directives: [{
568-
name: 'touch-pan',
569-
modifiers: {
570-
horizontal: true,
571-
mouse: true,
572-
mouseAllDir: true
573-
},
574-
value: this.__openByTouch
575-
}]
585+
directives: this.openDirective
576586
})
577587
: null,
578588

@@ -584,7 +594,9 @@ export default Vue.extend({
584594
? { backgroundColor: this.lastBackdropBg }
585595
: null,
586596
on: { click: this.hide },
587-
directives
597+
directives: this.noSwipeBackdrop !== true
598+
? this.closeDirective
599+
: void 0
588600
}) : null
589601
]
590602

@@ -613,8 +625,8 @@ export default Vue.extend({
613625
class: this.classes,
614626
style: this.style,
615627
on: this.onNativeEvents,
616-
directives: this.belowBreakpoint === true && this.noSwipeClose !== true
617-
? directives
628+
directives: this.noSwipeClose !== true
629+
? this.closeDirective
618630
: void 0
619631
}, content)
620632
]))

ui/src/components/layout/QDrawer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@
118118
"type": "Boolean",
119119
"desc": "Disables the default behavior where drawer can be swiped out of view (applies to drawer content only); Useful for iOS platforms where it might interfere with Safari's 'swipe to go to previous/next page' feature",
120120
"category": "behavior"
121+
},
122+
123+
"no-swipe-backdrop": {
124+
"type": "Boolean",
125+
"desc": "Disable the default behavior where drawer backdrop can be swiped",
126+
"category": "behavior",
127+
"addedIn": "v1.1.7"
121128
}
122129
},
123130

0 commit comments

Comments
 (0)