vueuse / vueuse

Collection of essential Vue Composition Utilities for Vue 2 and 3
https://vueuse.org
MIT License
18.88k stars 2.38k forks source link

useScroll - arrivedState.top bug in iOS Safari #3860

Open Nathan7139 opened 2 months ago

Nathan7139 commented 2 months ago

Describe the bug

In iOS Safari, there's a bug where the scrollTop property can be manipulated by user interaction to be less than zero, causing unexpected behavior in the useScroll function. The current implementation is: https://github.com/vueuse/vueuse/blob/9f10ad06a4fd2b4e6325dc72a3d1e36a62b6c254/packages/core/useScroll/index.ts#L218 To fix this issue, I suggest:

const top = scrollTop <= (offset.top || 0) 

Reproduction

https://github.com/vueuse/vueuse/assets/144317846/b09078c5-85e7-4e34-b89a-627c183f34ca

System Info

System:
    OS: macOS 14.3
    CPU: (8) arm64 Apple M1
    Memory: 68.70 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.15.1 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 8.11.0 - /usr/local/bin/npm
    pnpm: 8.7.6 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 122.0.6261.112
    Safari: 17.3
    Safari Technology Preview: 17.4
  npmPackages:
    @vueuse/core: ^10.3.0 => 10.7.2 
    vue: ^3.3.4 => 3.3.4

Used Package Manager

pnpm

Validations

yxiZo commented 1 month ago

I have encountered this issue as well. When I need to create ceiling animations, it leads to animation stuttering in the iOS environment.