@@ -3,10 +3,10 @@ import { css, cssTransform } from '../../utils/dom'
33import { between } from '../../utils/format'
44import { QResizeObservable } from '../observables'
55import ModelToggleMixin from '../../mixins/model-toggle'
6+ import { stopAndPrevent , getMouseWheelDistance , wheelEvent } from '../../utils/event'
67
78const
8- bodyClassBelow = 'with-layout-drawer-opened' ,
9- bodyClassAbove = 'with-layout-drawer-opened-above' ,
9+ bodyClass = 'q-drawer-scroll' ,
1010 duration = 150
1111
1212export default {
@@ -216,6 +216,11 @@ export default {
216216 } ,
217217 stateDirection ( ) {
218218 return ( this . $q . i18n . rtl ? - 1 : 1 ) * ( this . rightSide ? 1 : - 1 )
219+ } ,
220+ containerOn ( ) {
221+ if ( this . $q . platform . is . desktop ) {
222+ return { [ wheelEvent . name ] : this . __onWheel }
223+ }
219224 }
220225 } ,
221226 render ( h ) {
@@ -245,7 +250,10 @@ export default {
245250 } ) )
246251 }
247252
248- return h ( 'div' , { staticClass : 'q-drawer-container' } , child . concat ( [
253+ return h ( 'div' , {
254+ staticClass : 'q-drawer-container' ,
255+ on : this . containerOn
256+ } , child . concat ( [
249257 h ( 'aside' , {
250258 ref : 'content' ,
251259 staticClass : `q-layout-drawer q-layout-transition q-layout-drawer-${ this . side } scroll` ,
@@ -307,6 +315,12 @@ export default {
307315 applyBackdrop ( x ) {
308316 this . $refs . backdrop && css ( this . $refs . backdrop , { backgroundColor : `rgba(0,0,0,${ x * 0.4 } )` } )
309317 } ,
318+ __onWheel ( e ) {
319+ if ( this . fixed ) {
320+ stopAndPrevent ( e )
321+ this . $refs . content . scrollTop += getMouseWheelDistance ( e ) . pixelY
322+ }
323+ } ,
310324 __openByTouch ( evt ) {
311325 if ( ! this . belowBreakpoint ) {
312326 return
@@ -330,7 +344,6 @@ export default {
330344 this . applyBackdrop ( 0 )
331345 this . applyPosition ( this . stateDirection * width )
332346 el . classList . remove ( 'q-layout-drawer-delimiter' )
333- document . body . classList . remove ( bodyClassBelow )
334347 }
335348 } )
336349 return
@@ -347,7 +360,6 @@ export default {
347360
348361 if ( evt . isFirst ) {
349362 const el = this . $refs . content
350- document . body . classList . add ( bodyClassBelow )
351363 el . classList . add ( 'no-transition' )
352364 el . classList . add ( 'q-layout-drawer-delimiter' )
353365 }
@@ -389,6 +401,7 @@ export default {
389401 } ,
390402 __show ( ) {
391403 this . layout . __animate ( )
404+ this . applyPosition ( 0 )
392405
393406 if ( this . belowBreakpoint ) {
394407 const otherSide = this . layout . instances [ this . rightSide ? 'left' : 'right' ]
@@ -398,15 +411,15 @@ export default {
398411 this . mobileOpened = true
399412 this . applyBackdrop ( 1 )
400413 }
401-
402- this . applyPosition ( 0 )
403- document . body . classList . add ( this . belowBreakpoint ? bodyClassBelow : bodyClassAbove )
414+ else {
415+ document . body . classList . add ( bodyClass )
416+ }
404417
405418 clearTimeout ( this . timer )
406419 this . timer = setTimeout ( ( ) => {
407420 if ( this . showPromise ) {
408421 this . showPromise . then ( ( ) => {
409- document . body . classList . remove ( bodyClassAbove )
422+ document . body . classList . remove ( bodyClass )
410423 } )
411424 this . showPromiseResolve ( )
412425 }
@@ -420,8 +433,7 @@ export default {
420433 this . applyPosition ( ( this . $q . i18n . rtl ? - 1 : 1 ) * ( this . rightSide ? 1 : - 1 ) * this . size )
421434 this . applyBackdrop ( 0 )
422435
423- document . body . classList . remove ( bodyClassAbove )
424- document . body . classList . remove ( bodyClassBelow )
436+ document . body . classList . remove ( bodyClass )
425437
426438 this . timer = setTimeout ( ( ) => {
427439 this . hidePromise && this . hidePromiseResolve ( )
0 commit comments