Skip to content

Commit

Permalink
fix(directives): allow camelCase modifiers to work on UMD (#14556)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdanpdan committed Oct 5, 2022
1 parent 0fb32e1 commit 2b3f43e
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 20 deletions.
3 changes: 1 addition & 2 deletions ui/src/components/pull-to-refresh/QPullToRefresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ export default Vue.extend({
directives () {
if (this.disable !== true) {
const modifiers = {
down: true,
mightPrevent: true
down: true
}

if (this.noMouse !== true) {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/directives/TouchHold.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default {
el.__qtouchhold = ctx

modifiers.mouse === true && addEvt(ctx, 'main', [
[ el, 'mousedown', 'mouseStart', `passive${modifiers.mouseCapture === true ? 'Capture' : ''}` ]
[ el, 'mousedown', 'mouseStart', `passive${modifiers.mouseCapture === true || modifiers.mousecapture === true ? 'Capture' : ''}` ]
])

client.has.touch === true && addEvt(ctx, 'main', [
Expand Down
14 changes: 8 additions & 6 deletions ui/src/directives/TouchPan.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default {
*/
if (
ctx.direction.all !== true &&
(mouseEvent !== true || ctx.modifiers.mouseAllDir !== true)
(mouseEvent !== true || (ctx.modifiers.mouseAllDir !== true && ctx.modifiers.mousealldir !== true))
) {
const clone = evt.type.indexOf('mouse') > -1
? new MouseEvent(evt.type, evt)
Expand Down Expand Up @@ -256,7 +256,9 @@ export default {
const start = () => {
handleEvent(evt, isMouseEvt)

if (modifiers.preserveCursor !== true) {
let cursor
if (ctx.modifiers.preserveCursor !== true && ctx.modifiers.preservecursor !== true) {
cursor = document.documentElement.style.cursor || ''
document.documentElement.style.cursor = 'grabbing'
}
isMouseEvt === true && document.body.classList.add('no-pointer-events--children')
Expand All @@ -266,8 +268,8 @@ export default {
ctx.styleCleanup = withDelayedFn => {
ctx.styleCleanup = void 0

if (modifiers.preserveCursor !== true) {
document.documentElement.style.cursor = ''
if (cursor !== void 0) {
document.documentElement.style.cursor = cursor
}
document.body.classList.remove('non-selectable')

Expand Down Expand Up @@ -316,7 +318,7 @@ export default {

if (
ctx.direction.all === true ||
(isMouseEvt === true && ctx.modifiers.mouseAllDir === true)
(isMouseEvt === true && (ctx.modifiers.mouseAllDir === true || ctx.modifiers.mousealldir === true))
) {
start()
ctx.event.detected = true
Expand Down Expand Up @@ -387,7 +389,7 @@ export default {
el.__qtouchpan = ctx

modifiers.mouse === true && addEvt(ctx, 'main', [
[ el, 'mousedown', 'mouseStart', `passive${modifiers.mouseCapture === true ? 'Capture' : ''}` ]
[ el, 'mousedown', 'mouseStart', `passive${modifiers.mouseCapture === true || modifiers.mousecapture === true ? 'Capture' : ''}` ]
])

client.has.touch === true && addEvt(ctx, 'main', [
Expand Down
5 changes: 0 additions & 5 deletions ui/src/directives/TouchPan.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@
"desc": "Calls event.preventDefault() for touch events"
},

"mightPrevent": {
"type": "Boolean",
"desc": "Required when you might call event.preventDefault() in your handler for touch events"
},

"capture": {
"type": "Boolean",
"desc": "Use capture for touchstart event"
Expand Down
4 changes: 2 additions & 2 deletions ui/src/directives/TouchRepeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export default {
el.__qtouchrepeat = ctx

modifiers.mouse === true && addEvt(ctx, 'main', [
[ el, 'mousedown', 'mouseStart', `passive${modifiers.mouseCapture === true ? 'Capture' : ''}` ]
[ el, 'mousedown', 'mouseStart', `passive${modifiers.mouseCapture === true || modifiers.mousecapture === true ? 'Capture' : ''}` ]
])

client.has.touch === true && addEvt(ctx, 'main', [
Expand All @@ -227,7 +227,7 @@ export default {
])

keyboard.length > 0 && addEvt(ctx, 'main', [
[ el, 'keydown', 'keyboardStart', `notPassive${modifiers.keyCapture === true ? 'Capture' : ''}` ]
[ el, 'keydown', 'keyboardStart', `notPassive${modifiers.keyCapture === true || modifiers.keycapture === true ? 'Capture' : ''}` ]
])
},

Expand Down
2 changes: 1 addition & 1 deletion ui/src/directives/TouchSwipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default {
return
}

const mouseCapture = modifiers.mouseCapture === true ? 'Capture' : ''
const mouseCapture = modifiers.mouseCapture === true || modifiers.mousecapture === true ? 'Capture' : ''

const ctx = {
handler: value,
Expand Down
6 changes: 3 additions & 3 deletions ui/src/utils/morph.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ function normalizeOptions (options) {
fill: typeof options.fill === 'string' && options.fill.length > 0 ? options.fill : 'none',

resize: options.resize === true,
useCSS: options.useCSS === true,
hideFromClone: options.hideFromClone === true,
keepToClone: options.keepToClone === true,
useCSS: options.useCSS === true || options.usecss === true,
hideFromClone: options.hideFromClone === true || options.hidefromclone === true,
keepToClone: options.keepToClone === true || options.keeptoclone === true,

tween: options.tween === true,
tweenFromOpacity: isNaN(options.tweenFromOpacity) === true ? 0.6 : parseFloat(options.tweenFromOpacity),
Expand Down

0 comments on commit 2b3f43e

Please sign in to comment.