ampproject / amp-react-prototype

A scratch pad to experiment with React rendered AMP Components
Apache License 2.0
36 stars 9 forks source link

Playability: imperative vs declarative control #51

Open dvoytenko opened 4 years ago

dvoytenko commented 4 years ago

When an area of DOM (or component subtree) becomes unrendered or uninteractive, we need to pause relevant components. Otherwise the playback will continue and use will have no way of finding where it’s coming from and how to stop it.

For playability we can use AmpContext context properties.

For imperative/declarative control, playback is very difficult to support declaratively. This we can use useImperativeHandle and export playback API including playState, play, pause, and other similar methods.