-
-
Notifications
You must be signed in to change notification settings - Fork 772
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
Avoid setting marker opacity twice #5441
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5441 +/- ##
==========================================
- Coverage 91.95% 91.94% -0.01%
==========================================
Files 282 282
Lines 39050 39049 -1
Branches 6863 6862 -1
==========================================
- Hits 35907 35904 -3
- Misses 3016 3017 +1
- Partials 127 128 +1 ☔ View full report in Codecov by Sentry. |
Thanks for taking the time to fix this. |
@@ -857,16 +856,19 @@ export class Marker extends Evented { | |||
* @param opacityWhenCovered - Sets the `opacityWhenCovered` property of the marker. | |||
*/ | |||
setOpacity(opacity?: string, opacityWhenCovered?: string): this { | |||
if (opacity === undefined && opacityWhenCovered === undefined) { | |||
// Reset opacity when called without params or from constructor | |||
if (this._opacity === undefined || (opacity === undefined && opacityWhenCovered === undefined)) { |
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 think this method can be simplified even further:
this._opacity = opacity !== undefined ? opacity : '1';
this._opacityWhenCovered = opacityWhenCovered!== undefined ? opacityWhenCovered : '0.2';
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.
In the case of calling marker.setOpacity(something);
:
- the expected result is that
this._opacityWhenCovered
will not be changed - in the suggested code it will reset it to the default
'0.2'
same goes for calling marker.setOpacity(undefined, something);
I agree that a oneliner shortening is possible, but it will be somewhat less-understandable.
When creating a marker setOpacity was called twice, which results in calling _updateOpacity twice.
Also the opacity params are check twice for undefined.
This minor optimization solves the above.
Launch Checklist
CHANGELOG.md
under the## main
section.