Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(useMouse): updated scroll value #4191

Closed
wants to merge 22 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0966297
fix(useMouse): updated scroll value
pkc918 Sep 2, 2024
8efaa2d
chore: rename `pre` to `rev`
pkc918 Sep 2, 2024
187ff69
fix(useMouse): record the value of the previous scroll
pkc918 Sep 22, 2024
af30e67
fix(computedAsync): type signature (#4207)
ferferga Sep 12, 2024
1c6e860
fix(useIntersectionObserver): add `Document` type for root (#4210)
phk422 Sep 12, 2024
9b6b463
feat(useCurrentElement): try to infer type from `$el` (#4202)
KazariEX Sep 12, 2024
11fc816
docs(onKeyStroke): fix arrow down & up cause scroll event (#4199)
ArthurDarkstone Sep 12, 2024
af5b54d
fix(useMouseInElement): allow `el` to be instanceof Element (#4189)
FRSgit Sep 12, 2024
dd98b36
fix(onClickOutside): make `ignore` accept reactive values (#4211)
cernymatej Sep 12, 2024
81d59a4
fix(useDraggable): draggable component not work with container (#4192)
huiliangShen Sep 12, 2024
bed0a18
fix(useFocusWithin): make useFocusWhithin match the behavior of the :…
ben-lau Sep 12, 2024
02e0607
feat(useFileDialog): return `onCancel` handler (#4184)
AndreyYolkin Sep 12, 2024
528fed9
fix(onClickOutside): improve cross-browser compatibility (#4185)
Onion-L Sep 12, 2024
c8b7852
docs: typo in `useShare` docs (#4228)
AkaraChen Sep 16, 2024
383863c
fix(useResizeObserver): update type (#4218)
phk422 Sep 16, 2024
b82041b
fix(useNetwork): return immutable values (#4187)
rudnovd Sep 16, 2024
0c543ce
feat(useDropZone): add multiple prop to control multi-file drop (#4227)
danngossinga Sep 16, 2024
85db06f
fix(useInfiniteScroll): stop watch when unmounted (#4110)
zyyv Sep 16, 2024
6b2e810
fix(useArrayFilter): match type to Array.prototype.filter (#4175)
Jesse205 Sep 16, 2024
67647e8
chore: update deps, lint
antfu Sep 16, 2024
5be352b
chore: release v11.1.0
antfu Sep 16, 2024
5a65a1f
chore: update deps
antfu Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(useMouse): record the value of the previous scroll
  • Loading branch information
pkc918 committed Sep 22, 2024
commit 187ff69d74bdcda212257ba63e446b4f394dd43b
15 changes: 9 additions & 6 deletions packages/core/useMouse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ export function useMouse(options: UseMouseOptions = {}) {
} = options

let _prevMouseEvent: MouseEvent | null = null
let _prevScrollX = 0
let _prevScrollY = 0

const x = ref(initialValue.x)
const y = ref(initialValue.y)
const sourceType = ref<UseMouseSourceType>(null)

const prevScrollX = ref(0)
const prevScrollY = ref(0)
const extractor = typeof type === 'function'
? type
: UseMouseBuiltinExtractors[type]
Expand All @@ -98,8 +98,11 @@ export function useMouse(options: UseMouseOptions = {}) {
if (result) {
[x.value, y.value] = result
sourceType.value = 'mouse'
prevScrollX.value = window?.scrollX || 0
prevScrollY.value = window?.scrollY || 0
}

if (window) {
_prevScrollX = window.scrollX
_prevScrollY = window.screenY
}
}

Expand All @@ -119,8 +122,8 @@ export function useMouse(options: UseMouseOptions = {}) {
const pos = extractor(_prevMouseEvent)

if (_prevMouseEvent instanceof MouseEvent && pos) {
x.value = pos[0] + window.scrollX - prevScrollX.value
y.value = pos[1] + window.scrollY - prevScrollY.value
x.value = pos[0] + window.scrollX - _prevScrollX
y.value = pos[1] + window.scrollY - _prevScrollY
}
}

Expand Down
Loading