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

Trigger apply changed when mouse up #2133

Merged
merged 6 commits into from
Oct 17, 2023
Merged

Conversation

juliaroldi
Copy link
Contributor

Added a new parameters applyChangesOnMouseUp. If this parameter is true, when editing an image the last changes will be applied when mouse up event occurs. applyChangesOnMouseUp will be false by default.

@@ -179,6 +180,11 @@ export default class ImageEdit implements EditorPlugin {
e.preventDefault();
}
},
mouseup: e => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we already have mouse up event handler at line 185

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The handler in the switch case is not triggered when the mouse up event happens in the image wrapper.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. In that case, we should only attach this event handler when image wrapper is showing, and detach it when hide.

Also please try if we can attach the event to the wrapper element only, but not the whole window.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unless the user always have the cursor on the handles during the whole rotate and resize process, the event will not be triggered. Sometimes the cursor can move out from the handles.

resizeAndRotate

Copy link
Collaborator

Choose a reason for hiding this comment

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

Try pass true as the 3rd parameter when addEventListener, see if that can fix this problem:

node.addEventListener('mouseup', handler, true /*useCapture*/);

If that works, also need to pass true when remove event listener.

@@ -57,6 +57,10 @@ export default function applyChange(
newSrc,
});
newSrc = event.newSrc;
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

check the new parameter as well.

@juliaroldi juliaroldi merged commit 07ff0b6 into master Oct 17, 2023
7 checks passed
@juliaroldi juliaroldi deleted the u/juliaroldi/trigger-image branch October 17, 2023 17:00
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