Skip to content

Commit

Permalink
feat(touch events): use passive mode in more cases quasarframework#12822
Browse files Browse the repository at this point in the history
  • Loading branch information
pdanpdan committed Sep 30, 2022
1 parent 7b668f3 commit 4f5f067
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions ui/src/components/btn/QBtn.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { createComponent } from '../../utils/private/create.js'
import { hMergeSlot } from '../../utils/private/render.js'
import { stop, prevent, stopAndPrevent, listenOpts } from '../../utils/event.js'
import { isKeyCode } from '../../utils/private/key-composition.js'
import useSplitAttrs from '../../composables/private/use-split-attrs.js'

const { passiveCapture } = listenOpts

Expand All @@ -31,15 +32,16 @@ export default createComponent({

emits: [ 'click', 'keydown', 'touchstart', 'mousedown', 'keyup' ],

setup (props, { slots, emit }) {
const { proxy } = getCurrentInstance()
setup (props, { slots, emit, attrs }) {
const { proxy, vnode } = getCurrentInstance()

const {
classes, style, innerClasses,
attributes,
hasRouterLink, hasLink, linkTag, navigateToRouterLink,
isActionable
} = useBtn(props)
const { listeners } = useSplitAttrs(attrs, vnode)

const rootRef = ref(null)
const blurTargetRef = ref(null)
Expand Down Expand Up @@ -84,7 +86,7 @@ export default createComponent({
onClick,
onKeydown,
onMousedown,
onTouchstart
[ listeners.value.onTouchstart !== void 0 ? 'onTouchstart' : 'onTouchstartPassive' ]: onTouchstart
}
}

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 @@ -132,7 +132,7 @@ export default createDirective(__QUASAR_SSR_SERVER__

client.has.touch === true && addEvt(ctx, 'main', [
[ el, 'touchstart', 'touchStart', `passive${ modifiers.capture === true ? 'Capture' : '' }` ],
[ el, 'touchend', 'noop', 'notPassiveCapture' ]
[ el, 'touchend', 'noop', 'passiveCapture' ]
])
},

Expand Down
2 changes: 1 addition & 1 deletion ui/src/directives/TouchPan.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export default createDirective(__QUASAR_SSR_SERVER__

client.has.touch === true && addEvt(ctx, 'main', [
[ el, 'touchstart', 'touchStart', `passive${ modifiers.capture === true ? 'Capture' : '' }` ],
[ el, 'touchmove', 'noop', 'notPassiveCapture' ]
[ el, 'touchmove', 'noop', 'passiveCapture' ]
])
},

Expand Down
2 changes: 1 addition & 1 deletion ui/src/directives/TouchRepeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export default createDirective(__QUASAR_SSR_SERVER__

client.has.touch === true && addEvt(ctx, 'main', [
[ el, 'touchstart', 'touchStart', `passive${ modifiers.capture === true ? 'Capture' : '' }` ],
[ el, 'touchend', 'noop', 'notPassiveCapture' ]
[ el, 'touchend', 'noop', 'passiveCapture' ]
])

keyboard.length > 0 && addEvt(ctx, 'main', [
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 @@ -234,7 +234,7 @@ export default createDirective(__QUASAR_SSR_SERVER__

client.has.touch === true && addEvt(ctx, 'main', [
[ el, 'touchstart', 'touchStart', `passive${ modifiers.capture === true ? 'Capture' : '' }` ],
[ el, 'touchmove', 'noop', 'notPassiveCapture' ]
[ el, 'touchmove', 'noop', 'passiveCapture' ]
])
},

Expand Down

0 comments on commit 4f5f067

Please sign in to comment.