Window & Dynamic Size List Virtualization Causes Mobile Safari IOS Scroll Momentum Interruption
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- react, typescript
- Domínio
- frontend, performance
Direção de pesquisa
Comece com a reprodução fornecida no CodeSandbox e o exemplo useWindowVirtualizer, testando-os no Mobile iOS Safari com itens de tamanho dinâmico. Investigue a interação entre os elementos medidos que estão sendo virtualizados e o momentum da rolagem da janela; considera-se concluído quando a reprodução mantém uma rolagem com momentum suave enquanto a virtualização permanece ativa.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Describe the bug
By using the useWindowVirtualizer hook to apply virtualization for list items with different heights in relation to window scrolling, when you scroll, the virtualization behavior will occur.
Items that no longer need to be rendered will disappear from the DOM, and the list items corresponding to the visible indices will begin to appear in the DOM.
On Mobile iOS Safari, momentum scrolling triggered by user gestures works, but when combined with virtualization, the momentum effect fails to end smoothly and instead stutters or breaks abruptly. Is there a way to resolve this issue?
import "./styles.css";
import { useWindowVirtualizer } from "@tanstack/react-virtual";
const createRandomHeights = (
min: number,
max: number,
count: number = 1000
) => {
const heights = [];
for (let i = 0; i < count; i++) {
heights.push(Math.floor(Math.random() * (max - min + 1) + min));
}
return heights;
};
const randomHeights = createRandomHeights(100, 400);
const colors = ["red", "yellow", "blue"];
export default function App() {
const virtualizer = useWindowVirtualizer({
count: 1000,
estimateSize: () => 400,
overscan: 5,
scrollMargin: 0,
});
const virtualItems = virtualizer.getVirtualItems();
return (
<div>
<div
style={{
height: `${virtualizer.getTotalSize()}px`,
position: "relative",
width: "100%",
}}
>
<div
style={{
transform: `translateY(${
(virtualItems[0]?.start ?? 0) - virtualizer.options.scrollMargin
}px)`,
position: "absolute",
left: "0",
top: "0",
width: "100%",
}}
>
{virtualItems.map((virtualItem) => {
return (
<div
key={virtualItem.key}
data-index={virtualItem.index}
ref={virtualizer.measureElement}
style={{
paddingTop: "40px",
}}
>
<div
style={{
height: randomHeights[virtualItem.index],
backgroundColor: colors[virtualItem.index % 3],
}}
></div>
</div>
);
})}
</div>
</div>
</div>
);
}
Your minimal, reproducible example
https://codesandbox.io/p/sandbox/qhkvyz
Steps to reproduce
- Go to CodeSandbox Link
- Scroll down Preview Page
- As you scroll, the momentum scroll stops occurring and the scrolling becomes increasingly choppy.
Expected behavior
I hope to maintain a seamless momentum scroll experience.
How often does this bug happen?
Every time
Screenshots or Videos
https://github.com/user-attachments/assets/2b27fcd6-e3de-449b-ac20-2633d76619d3
https://github.com/user-attachments/assets/166be2b0-cab1-495a-a9e1-9b770e31c1fc
Platform
- OS: IOS
- Browser: Safari
- Version: 18.1, 17.6.1
tanstack-virtual version
v3.10.6
TypeScript version
v5.4.5
Additional context
It seems that the CodeSandbox link is difficult to run on Mobile iOS Safari at the moment. However, you can reproduce the issue by running the attached source code.
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
- Linguagem predominante
- TypeScript
- Estrelas
- 7.1k
- Forks
- 468
- Merge médio
- 1d 2h
- PRs com merge (30d)
- 12
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TanStack/virtual
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 55/100
TanStack/virtual#1290 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 38/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 55/100
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/virtual
Issues semelhantes
-
priority: P2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
prime-radiant-inc/evener#3291 ·
Mantenedores costumam responder em até 1 dia
-
accessibility bug revealjs
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
quarto-dev/quarto-cli#14961 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
supabase/agent-skills#614 ·
-
Content
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
RunestoneInteractive/rs#1559 · 1 comentário ·
Mantenedores costumam responder em até 2 dias