Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[p5.js 2.0+ Bug Report]: touches[0].x lags one pointer event behind while dragging

未关闭 适合新手
#9,305 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

@titanstride 已经在做这个了。

开始于 2026年10月17日。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript
领域
frontend

调研方向

从 src/events/pointer.js 开始,重点查看 _onpointermove 和 _updatePointerCoords;issue 报告称,坐标在活动指针存储之前就已更新。运行或扩展报告中提到的本地 handler 测试,并在可能的情况下通过 sketch 验证行为。完成标准是 touches[0].x 在与 mouseX 相同的移动事件期间反映当前触摸位置。

由索引模型根据 Issue 内容生成。

描述

Area:Events p5.js 2.0+
Most appropriate sub-area of p5.js?
  • Events
p5.js version

2.3.2

Web browser and version

Brave || 1.97.59

Operating system

macOS (local code-path test)

Steps to reproduce this
  1. Run a p5.js 2.3.2 sketch on a touch device, or enable touch emulation in browser DevTools.
  2. Drag one touch across the canvas while logging mouseX and touches[0].x in touchMoved().
  3. Compare the values on each move. In the local handler test, moving the touch from x=50 to x=150 updated mouseX to 150 while touches[0].x stayed at 50. On the next move, touches[0].x changed to 150.
Snippet
function setup() {
  createCanvas(300, 100);
}

function touchMoved() {
  console.log('mouseX:', mouseX, 'touchX:', touches[0] && touches[0].x);
}
Expected behavior

touches[0].x should reflect the current touch position during the move event.

Actual behavior and likely cause

The latest position appears in mouseX, but touches[0].x is one pointer event behind. In src/events/pointer.js, _onpointermove calls _updatePointerCoords(e) before storing the new event in _activePointers. The coordinate updater rebuilds touches from _activePointers, so it reads the previous event. This was confirmed with a direct local handler test; I have not yet verified the sketch end to end in a browser.

主要语言
JavaScript
星标
24.1k
派生
3.9k
平均合并
2 天 16 小时
30 天内合并 PR
33

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

processing/p5.js 的其他 Issue

查看 processing/p5.js 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。