Skip to content

Commit 0187213

Browse files
committed
fix(QSplitter/QScrollArea/QPullToRefresh): correctly handle v-touch-pan modifiers change quasarframework#7684
1 parent 8964ad6 commit 0187213

File tree

5 files changed

+77
-45
lines changed

5 files changed

+77
-45
lines changed

ui/src/components/pull-to-refresh/QPullToRefresh.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,18 @@ export default Vue.extend({
6363

6464
directives () {
6565
if (this.disable !== true) {
66+
const modifiers = {
67+
down: true,
68+
mightPrevent: true
69+
}
70+
71+
if (this.noMouse !== true) {
72+
modifiers.mouse = true
73+
}
74+
6675
return [{
6776
name: 'touch-pan',
68-
modifiers: {
69-
down: true,
70-
mightPrevent: true,
71-
mouse: this.noMouse !== true
72-
},
77+
modifiers,
7378
value: this.__pull
7479
}]
7580
}

ui/src/components/scroll-area/QScrollArea.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@ export default Vue.extend({
125125
barClass () {
126126
return `q-scrollarea__bar--${this.dirProps.classSuffix}` +
127127
(this.thumbHidden === true ? ' q-scrollarea__bar--invisible' : '')
128+
},
129+
130+
thumbDirectives () {
131+
return [{
132+
name: 'touch-pan',
133+
modifiers: {
134+
[ this.horizontal === true ? 'horizontal' : 'vertical' ]: true,
135+
prevent: true,
136+
mouse: true,
137+
mouseAllDir: true
138+
},
139+
value: this.__panThumb
140+
}]
128141
}
129142
},
130143

@@ -285,17 +298,7 @@ export default Vue.extend({
285298
style: this.style,
286299
class: this.thumbClass,
287300
attrs: ariaHidden,
288-
directives: cache(this, 'thumb#' + this.horizontal, [{
289-
name: 'touch-pan',
290-
modifiers: {
291-
vertical: this.horizontal !== true,
292-
horizontal: this.horizontal,
293-
prevent: true,
294-
mouse: true,
295-
mouseAllDir: true
296-
},
297-
value: this.__panThumb
298-
}])
301+
directives: this.thumbDirectives
299302
})
300303
])
301304
},

ui/src/components/slide-item/QSlideItem.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import DarkMixin from '../../mixins/dark.js'
66
import ListenersMixin from '../../mixins/listeners.js'
77

88
import { slot } from '../../utils/slot.js'
9+
import { cacheWithFn } from '../../utils/cache.js'
910

1011
const slotsDef = [
1112
['left', 'center', 'start', 'width'],
@@ -137,10 +138,13 @@ export default Vue.extend({
137138
render (h) {
138139
const
139140
content = [],
140-
left = this.$scopedSlots[this.langDir.right] !== void 0,
141-
right = this.$scopedSlots[this.langDir.left] !== void 0,
142-
up = this.$scopedSlots.bottom !== void 0,
143-
down = this.$scopedSlots.top !== void 0
141+
slots = {
142+
left: this.$scopedSlots[this.langDir.right] !== void 0,
143+
right: this.$scopedSlots[this.langDir.left] !== void 0,
144+
up: this.$scopedSlots.bottom !== void 0,
145+
down: this.$scopedSlots.top !== void 0
146+
},
147+
dirs = Object.keys(slots).filter(key => slots[key] === true)
144148

145149
slotsDef.forEach(slot => {
146150
const dir = slot[0]
@@ -163,19 +167,25 @@ export default Vue.extend({
163167
ref: 'content',
164168
key: 'content',
165169
staticClass: 'q-slide-item__content',
166-
directives: left === true || right === true || up === true || down === true ? [{
167-
name: 'touch-pan',
168-
value: this.__pan,
169-
modifiers: {
170-
left,
171-
right,
172-
up,
173-
down,
174-
prevent: true,
175-
stop: true,
176-
mouse: true
177-
}
178-
}] : null
170+
directives: dirs.length > 0
171+
? cacheWithFn(this, 'dir#' + dirs.join(''), () => {
172+
const modifiers = {
173+
prevent: true,
174+
stop: true,
175+
mouse: true
176+
}
177+
178+
dirs.forEach(dir => {
179+
modifiers[dir] = true
180+
})
181+
182+
return [{
183+
name: 'touch-pan',
184+
value: this.__pan,
185+
modifiers
186+
}]
187+
})
188+
: null
179189
}, slot(this, 'default'))
180190
)
181191

ui/src/components/splitter/QSplitter.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@ export default Vue.extend({
9797
[this.prop]: this.__getCSSValue(this.value)
9898
}
9999
}
100+
},
101+
102+
separatorDirectives () {
103+
if (this.disable !== true) {
104+
return [{
105+
name: 'touch-pan',
106+
value: this.__pan,
107+
modifiers: {
108+
[ this.horizontal === true ? 'vertical' : 'horizontal' ]: true,
109+
prevent: true,
110+
stop: true,
111+
mouse: true,
112+
mouseAllDir: true
113+
}
114+
}]
115+
}
100116
}
101117
},
102118

@@ -172,18 +188,7 @@ export default Vue.extend({
172188
}, [
173189
h('div', {
174190
staticClass: 'absolute-full q-splitter__separator-area',
175-
directives: this.disable === true ? void 0 : cache(this, 'dir#' + this.horizontal, [{
176-
name: 'touch-pan',
177-
value: this.__pan,
178-
modifiers: {
179-
horizontal: this.horizontal !== true,
180-
vertical: this.horizontal,
181-
prevent: true,
182-
stop: true,
183-
mouse: true,
184-
mouseAllDir: true
185-
}
186-
}])
191+
directives: this.separatorDirectives
187192
}, slot(this, 'separator'))
188193
]),
189194

ui/src/utils/cache.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ export default function cache (vm, key, obj) {
99
: vm[k]
1010
}
1111

12+
export function cacheWithFn (vm, key, fn) {
13+
if (isSSR === true) return fn()
14+
15+
const k = `__qcache_${key}`
16+
return vm[k] === void 0
17+
? (vm[k] = fn())
18+
: vm[k]
19+
}
20+
1221
export function getPropCacheMixin (propName, proxyPropName) {
1322
return {
1423
data () {

0 commit comments

Comments
 (0)