benwiley4000 / react-gif-player

📽 A GIF component that moves when YOU want it to!
https://benwiley4000.github.io/react-gif-player/
MIT License
94 stars 32 forks source link

GIF Player: add on change props to listen to gif play/pause #21

Closed AquiGorka closed 6 years ago

AquiGorka commented 6 years ago

@benwiley4000 hello again, another PR here:

This changes introduce an onChange prop to listen to changes in the gif state (play/pause).

benwiley4000 commented 6 years ago

Also I'm thinking about it and we could probably me more descriptive than "onChange". Maybe "onTogglePlay" or something? In case we have to add other handlers later on.

AquiGorka commented 6 years ago

I prefer the form:

if (typeof this.props.onChange === 'function') {
this.props.onChange(...);
}

Added destructuring with default value, let me know if this is alright with you.

I also prefer handling this in componentDidUpdate - we can just check if the playing state is different than the last.

Done.

Semicolon would be great. 😉

;)

AquiGorka commented 6 years ago

@benwiley4000 will you let me know when you update on npm? I have an app eager to use this update ;)

benwiley4000 commented 6 years ago

@AquiGorka yep it's out! v0.4.0. 🙂