@@ -48,7 +48,8 @@ export default Vue.extend({
4848
4949 computed : {
5050 thumbHidden ( ) {
51- return this . scrollSize <= this . containerSize || ( ! this . active && ! this . hover )
51+ return this . scrollSize <= this . containerSize ||
52+ ( this . active === false && this . hover === false )
5253 } ,
5354
5455 thumbSize ( ) {
@@ -89,7 +90,9 @@ export default Vue.extend({
8990 } ,
9091
9192 direction ( ) {
92- return this . horizontal ? 'right' : 'down'
93+ return this . horizontal === true
94+ ? 'right'
95+ : 'down'
9396 } ,
9497
9598 containerSize ( ) {
@@ -111,20 +114,30 @@ export default Vue.extend({
111114 } ,
112115
113116 methods : {
117+ getScrollTarget ( ) {
118+ return this . $refs . target
119+ } ,
120+
121+ getScrollPosition ( ) {
122+ return this . $q . platform . is . desktop === true
123+ ? this . scrollPosition
124+ : this . $refs . target [ this . dirProps . el ]
125+ } ,
126+
114127 setScrollPosition ( offset , duration ) {
115- if ( this . horizontal === true ) {
116- setHorizontalScrollPosition ( this . $refs . target , offset , duration )
117- }
118- else {
119- setScrollPosition ( this . $refs . target , offset , duration )
120- }
128+ const fn = this . horizontal === true
129+ ? setHorizontalScrollPosition
130+ : setScrollPosition
131+
132+ fn ( this . $refs . target , offset , duration )
121133 } ,
122134
123135 __updateContainer ( { height, width } ) {
124136 if ( this . containerWidth !== width ) {
125137 this . containerWidth = width
126138 this . __setActive ( true , true )
127139 }
140+
128141 if ( this . containerHeight !== height ) {
129142 this . containerHeight = height
130143 this . __setActive ( true , true )
@@ -154,12 +167,12 @@ export default Vue.extend({
154167 } ,
155168
156169 __panThumb ( e ) {
157- if ( e . isFirst ) {
170+ if ( e . isFirst === true ) {
158171 this . refPos = this . scrollPosition
159172 this . __setActive ( true , true )
160173 }
161174
162- if ( e . isFinal ) {
175+ if ( e . isFinal === true ) {
163176 this . __setActive ( false )
164177 }
165178
@@ -170,16 +183,18 @@ export default Vue.extend({
170183 } ,
171184
172185 __panContainer ( e ) {
173- if ( e . isFirst ) {
186+ if ( e . isFirst === true ) {
174187 this . refPos = this . scrollPosition
175188 this . __setActive ( true , true )
176189 }
177- if ( e . isFinal ) {
190+ if ( e . isFinal === true ) {
178191 this . __setActive ( false )
179192 }
180193
181- const distance = this . horizontal ? e . distance . x : e . distance . y
182- const pos = this . refPos + ( e . direction === this . direction ? - 1 : 1 ) * distance
194+ const distance = e . distance [ this . horizontal === true ? 'x' : 'y' ]
195+ const pos = this . refPos +
196+ ( e . direction === this . direction ? - 1 : 1 ) * distance
197+
183198 this . __setScroll ( pos )
184199
185200 if ( pos > 0 && pos + this . containerSize < this . scrollSize ) {
@@ -191,7 +206,11 @@ export default Vue.extend({
191206 const el = this . $refs . target
192207
193208 el [ this . dirProps . el ] += getMouseWheelDistance ( e ) [ this . dirProps . wheel ]
194- if ( el [ this . dirProps . el ] > 0 && el [ this . dirProps . el ] + this . containerSize < this . scrollSize ) {
209+
210+ if (
211+ el [ this . dirProps . el ] > 0 &&
212+ el [ this . dirProps . el ] + this . containerSize < this . scrollSize
213+ ) {
195214 prevent ( e )
196215 }
197216 } ,
@@ -224,13 +243,13 @@ export default Vue.extend({
224243 } , this . delay )
225244 } ,
226245
227- __setScroll ( scroll ) {
228- this . $refs . target [ this . dirProps . el ] = scroll
246+ __setScroll ( offset ) {
247+ this . $refs . target [ this . dirProps . el ] = offset
229248 }
230249 } ,
231250
232251 render ( h ) {
233- if ( ! this . $q . platform . is . desktop ) {
252+ if ( this . $q . platform . is . desktop !== true ) {
234253 return h ( 'div' , {
235254 staticClass : 'q-scroll-area' ,
236255 style : this . contentStyle
@@ -275,6 +294,7 @@ export default Vue.extend({
275294 } ) ,
276295 slot ( this , 'default' )
277296 ] ) ,
297+
278298 h ( QScrollObserver , {
279299 props : { horizontal : this . horizontal } ,
280300 on : { scroll : this . __updateScroll }
0 commit comments