Skip to content

Commit de93742

Browse files
committed
feat(QDrawer): new event - @mini-state - triggered when mini-mode state changes quasarframework#5118
1 parent 2023c43 commit de93742

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

ui/dev/components/layout/layout.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
side="left"
151151
:mini="leftMini"
152152
:mini-width="72"
153+
@mini-state="onMiniState"
153154
:bordered="bordered"
154155
:elevated="elevated"
155156
@click.capture="e => {
@@ -571,6 +572,9 @@ export default {
571572
else {
572573
console.log('goNormal abort')
573574
}
575+
},
576+
onMiniState (val) {
577+
console.log('left drawer @mini-state ->', val)
574578
}
575579
}
576580
}

ui/src/components/layout/QDrawer.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export default Vue.extend({
142142
},
143143

144144
onLayout (val) {
145-
this.$listeners['on-layout'] !== void 0 && this.$emit('on-layout', val)
145+
this.$emit('on-layout', val)
146146
this.__update('space', val)
147147
},
148148

@@ -168,6 +168,10 @@ export default Vue.extend({
168168
this.__animateMini()
169169
this.layout.__animate()
170170
}
171+
},
172+
173+
isMini (val) {
174+
this.$emit('mini-state', val)
171175
}
172176
},
173177

@@ -501,7 +505,8 @@ export default Vue.extend({
501505
},
502506

503507
mounted () {
504-
this.$listeners['on-layout'] !== void 0 && this.$emit('on-layout', this.onLayout)
508+
this.$emit('on-layout', this.onLayout)
509+
this.$emit('mini-state', this.isMini)
505510

506511
const fn = () => {
507512
if (this.showing === true) {

ui/src/components/layout/QDrawer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,17 @@
155155
"mouseout": {
156156
"extends": "click",
157157
"desc": "Emitted when user moves mouse cursor out of the component and drawer is NOT in mobile mode; Useful for when taking a decision to toggle mini mode"
158+
},
159+
160+
"mini-state": {
161+
"desc": "Emitted when drawer changes the mini-mode state (sometimes it is forced to do so)",
162+
"params": {
163+
"state": {
164+
"type": "Boolean",
165+
"desc": "New state"
166+
}
167+
},
168+
"addedIn": "v1.1.3"
158169
}
159170
}
160171
}

0 commit comments

Comments
 (0)