JustFly1984 / react-google-maps-api

React Google Maps API
MIT License
1.75k stars 426 forks source link

MarkerF animations will not stop #3247

Closed jneander closed 1 year ago

jneander commented 1 year ago

Issue template

You can donate or became a sponsor https://opencollective.com/react-google-maps-api#category-CONTRIBUTE

If you want to ask question, please ask it in Github Discussions, Spectrum.chat or Slack channel

Please do not post unformatted code into issues, and please do not ask questions. Only real issues, PR's or feature requests are allowed. Minimal reproduction in codesandbox.io is required.

Please provide an explanation of the issue

When using the MarkerF component with animations, animations are not stopped when a null, undefined, or otherwise falsy value is provided. The reason can be traced to https://github.com/JustFly1984/react-google-maps-api/blob/develop/packages/react-google-maps-api/src/components/drawing/Marker.tsx#L282-L284, where .setAnimation() is not called on the Marker instance unless the value is truthy.

Your Environment

os: mac

node --version: v18.16.0

react version: 18.2.0

webpack version: 5.78.0

@babel version: 7.21.4

@react-google-maps/api version: 2.18.1

How does it behave?

When an animation is applied to a MarkerF component, it will continue that animation until replaced with a different animation. It will never stop.

How should it behave correctly?

When the MarkerF component receives any value appropriate for the Google Map Marker#setAnimation() method, that method should be called with that value. This includes undefined as a value which stops an animation.

Basic implementation of incorrect behavior in codesandbox.com

ewillroth commented 1 year ago

I am also seeing this issue. Has anyone found a workaround until the fix has been merged?