GoogleChrome / dialog-polyfill

Polyfill for the HTML dialog element
BSD 3-Clause "New" or "Revised" License
2.45k stars 245 forks source link

Forward mouseup and mousedown too. #197

Closed daiplusplus closed 4 years ago

daiplusplus commented 4 years ago

In my application, I detect clicks on the backdrop by comparing the MouseEvent's x and y coordinates to the dialog's box dimensions and closing the dialog if the user clicked on the backdrop.

However I can't simply use the 'click' event because my dialogs are resizable (using the browser native resize grip in the bottom-right corner of the dialog). If a user drags the resize handle to make the dialog bigger - and if the dialog has a max-width and/or max-height and the user keeps on dragging the mouse cursor and releases their mouse button over the backdrop then the 'click' event is raised with the MouseEvent coordinates over the backdrop - so I use the mouseup and mousedown events to detect if the mouse moved between the backdrop and the dialog-proper (again, by comparing coordinates of the MouseEvent with the size of the dialog-proper), and based on that it either ignores the click or it closes the dialog.

My solution works with this Polyfill library, but I first needed to invoke the backdropClick_ function for mouseup and mousedown events - so this is me contributing those trivial changes back.

googlebot commented 4 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

googlebot commented 4 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

daiplusplus commented 4 years ago

@googlebot I signed it!

googlebot commented 4 years ago

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

googlebot commented 4 years ago

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

samthor commented 4 years ago

Thanks!