Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-4305: After panning, sometimes zooming doesn't zoom into the mouse position #13095

Merged
merged 7 commits into from
Aug 2, 2022

Conversation

sm6srw
Copy link
Contributor

@sm6srw sm6srw commented Jul 11, 2022

Purpose

This pull request does:

  • add code to stop sending view notifications when no changes have been made during pan/zoom
  • fix two bugs that cause the offset to not update correctly.

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

Release Notes

Initiating a zoom right after a pan no longer sporadically zooms around the wrong position.

Reviewers

(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)

(FILL ME IN, optional) Any additional notes to reviewers or testers.

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

@sm6srw sm6srw added the WIP label Jul 11, 2022
tt.X = p.X;
tt.Y = p.Y;
var tt = GetChildTranslateTransform();
if (tt.X != p.X || tt.Y != p.Y)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Keeping code that stops propagation if nothing has changed.

}

#region Child Events

private void child_MouseWheel(object sender, MouseWheelEventArgs e)
{
if (child != null)
if (child != null && !child.IsMouseCaptured)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do not allow zoom if middle button is down. This caused zoom to jump.

@@ -1310,7 +1310,7 @@ private void SetCurrentOffset(object parameter)

//set the current offset without triggering
//any property change notices.
if (Model.X != p.X && Model.Y != p.Y)
if (Model.X != p.X || Model.Y != p.Y)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the second bug. Zoom jumped if only X or Y changed during pan.

@sm6srw sm6srw removed the WIP label Aug 2, 2022
@@ -173,6 +178,12 @@ private void child_MouseMove(object sender, MouseEventArgs e)

// Change ZoomBorder's child translation
Vector v = start - e.GetPosition(this);

if (v.Length == 0.0)
Copy link
Contributor

@pinzart90 pinzart90 Aug 2, 2022

Choose a reason for hiding this comment

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

maybe use a tolerance ? I guess it does not matter that much...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking of it but the values I have seen here have been 0,1,2 etc and 0 has been 0 in those cases. So I think this is good enough.

{
st.ScaleX = zoom;
st.ScaleY = zoom;
var tt = GetTranslateTransform(child);
Copy link
Contributor

Choose a reason for hiding this comment

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

GetChildTranslateTransform() ?
I saw you used this method at line 103

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, could be used here. I may do a pass and use the child version of these methods.

Copy link
Contributor

@pinzart90 pinzart90 left a comment

Choose a reason for hiding this comment

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

A couple of minor comments

@sm6srw sm6srw merged commit 99215f1 into DynamoDS:master Aug 2, 2022
@sm6srw sm6srw deleted the DYN-4305 branch August 2, 2022 17:12
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.

2 participants