Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#9,305 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

@titanstride đang làm issue này rồi.

Từ ngày 17/10/2026.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu tại src/events/pointer.js, tập trung vào _onpointermove và _updatePointerCoords; issue cho biết tọa độ được cập nhật trước khi con trỏ đang hoạt động được lưu. Chạy hoặc mở rộng bài kiểm tra handler cục bộ được đề cập trong báo cáo, và nếu có thể, hãy xác minh hành vi trong một sketch. Công việc được xem là hoàn tất khi touches[0].x phản ánh vị trí chạm hiện tại trong cùng sự kiện di chuyển với mouseX.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
JavaScript
Star
24.1k
Fork
3.9k
Merge trung bình
2 ngày 20 giờ
Pull request đã merge (30 ngày)
37

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của processing/p5.js

Tất cả issue của processing/p5.js

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.