Skip to content

Conversation

hxrshxz
Copy link

@hxrshxz hxrshxz commented Oct 12, 2025

Resolves #8139

Changes:

  • Store last mouse event in _updateNextMouseCoords()
  • Recalculate mouse coordinates in _onresize() using stored event

PR Checklist

@Copilot Copilot AI review requested due to automatic review settings October 12, 2025 12:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where mouseX and mouseY coordinates were not being updated when the canvas was resized, causing them to become inaccurate relative to the new canvas dimensions.

  • Store the last mouse event in _updateNextMouseCoords() for later use
  • Recalculate mouse coordinates during window resize using the stored event
  • Ensure mouse coordinates remain accurate after canvas size changes

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/events/mouse.js Store last mouse event for coordinate recalculation
src/core/environment.js Update mouse coordinates on window resize using stored event

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@hxrshxz hxrshxz requested a review from Copilot October 12, 2025 12:08
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@hxrshxz hxrshxz force-pushed the fix-mouse-resize-8139 branch from 99a7f99 to 555ba23 Compare October 12, 2025 12:22
@hxrshxz hxrshxz requested a review from Copilot October 12, 2025 12:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

this._setProperty('windowHeight', getWindowHeight());
// Update mouse coordinates when window resizes
// This ensures mouseX/mouseY reflect the mouse position relative to the new canvas size
if (this._hasMouseInteracted && this._lastMouseEvent) {
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition checks _hasMouseInteracted but this property may not be initialized. Consider adding a null check or ensuring this property is properly initialized before use.

Copilot uses AI. Check for mistakes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_hasMouseInteracted is initialized to false on line 117 of mouse.js (p5.prototype._hasMouseInteracted = false;), so it's always defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mouseX and mouseY not updated when canvas changes until mouse moves

1 participant