Skip to content

Commit

Permalink
fix(usePointerSwipe): use style.setProperty instead of `setAttribut…
Browse files Browse the repository at this point in the history
…e` (#583)

* fix : replace `setAttribute` with `style.setProperty` in usePointerSwipe

* nullable chaining and single quotes

* Delete package-lock.json

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
jeffrey-dot-li and antfu committed Jul 5, 2021
1 parent 97328e6 commit d09fb9a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/core/usePointerSwipe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface PointerSwipeReturn {
* @param options
*/
export function usePointerSwipe(
target: MaybeRef<Element | null | undefined>,
target: MaybeRef<HTMLElement | null | undefined>,
options: PointerSwipeOptions = {},
): PointerSwipeReturn {
const targetRef = ref(target)
Expand Down Expand Up @@ -99,7 +99,7 @@ export function usePointerSwipe(
useEventListener(target, 'pointerdown', (e: PointerEvent) => {
isPointerDown.value = true
// Disable scroll on for TouchEvents
targetRef.value?.setAttribute('style', 'touch-action: none')
targetRef.value?.style?.setProperty('touch-action', 'none')
// Future pointer events will be retargeted to target until pointerup/cancel
targetRef.value?.setPointerCapture(e.pointerId)

Expand Down Expand Up @@ -127,7 +127,7 @@ export function usePointerSwipe(

isPointerDown.value = false
isSwiping.value = false
targetRef.value?.setAttribute('style', 'touch-action: initial')
targetRef.value?.style?.setProperty('touch-action', 'initial')
}),
]

Expand Down

0 comments on commit d09fb9a

Please sign in to comment.