-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Use overlayLayer and overlayMouseTarget #518
Conversation
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). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@@ -120,31 +121,37 @@ ClusterIcon.prototype.onAdd = function () { | |||
|
|||
this.div_ = document.createElement("div"); | |||
this.div_.className = this.className_; | |||
this.eventDiv_ = this.div_.cloneNode(); | |||
this.eventDiv_.className += ' event'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for adding the "event" class name to the overlayMouseTarget div? Shouldn't it be exactly the same class as the overlayLayer div?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to have a way to differentiate the visible div, div.classname
and the event div, div.classname.event
. The same class configured by the user is on both divs, but event is added so that you can use a :not
or other selector.
I guess I could use a more BEM friendly div.classname.div.classname--event
if you'd prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two divs should be absolutely identical, so I think it's best if the overlayMouseTarget div has exactly the same class as the overlayLayer div.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
this.syncDivStyle({ | ||
title: this.div_.title, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you have to synch the display style as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intention was only to set the props that the code sets on the visible div. Line 388 copies all of the css set on this.div_
Edit: for grammar, typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -286,6 +298,10 @@ ClusterIcon.prototype.show = function () { | |||
this.div_.title = this.sums_.title; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just before this line you should also be setting the innerHTML of the overlayMouseTarget div to the same as that of the overlayLayer div. This ensures the overlayMouseTarget div has exactly the same size as the overlayLayer div.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wouldn't copying the height and width from the overlayDiv work without duplicating innerHTML?
I'm open to setting it and adding opacity: 0
to line 388; it just seems unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just being cautious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syncing innerHTML to event div and setting opacity when css is updated (in syncDivStyle
method)
*/ | ||
ClusterIcon.prototype.syncDivStyle = function (vars) { | ||
if (vars) { | ||
Object.assign(this.eventDiv_, vars); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is used to sync any other DOMElement props outside of CSS. The only property I found that needed this was the title
.
@googlebot I signed it! |
1 similar comment
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Object.assign(this.eventDiv_, vars); | ||
} | ||
if (this.eventDiv_ && this.div_) { | ||
this.eventDiv_.style.cssText = this.div_.style.cssText; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overlayDiv, this.div_
, is positioned and resized using CSS. By copying the cssText we copy the same height, width, z-index, etc. without having to specify each.
I noticed that there's a big ES6 rewrite happening. Is this fix still necessary? |
@ashleahhill I'm not sure when I will get to rewriting this one. I'll defer to @garylittleRLP for the comments already made here. |
I'm also fine with rebasing this off of the 3.0 work or opening another PR for 3.0. |
closing in favor of #558 |
@ashleahhill see #558 (comment) to consent to your commit being merged |
Currently, the lib is drawing the visible target on the overlayMouseTarget layer instead of the overlayLayer. My understanding of how these layers are supposed to work is: visuals on overlay layer, synced, invisible eventTargets on the overlayMouseTarget layer.
I came to this conclusion by picking apart the default map markers and this documentation: https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes
With this setup, the z-index logic can remain simple and the clusters will continue to show up over pins but under other UI.
fixes #506