anthonyshort / deku

Render interfaces using pure functions and virtual DOM
https://github.com/anthonyshort/deku/tree/master/docs
3.41k stars 130 forks source link

Add HTML5 media events #293

Closed 84564221 closed 8 years ago

84564221 commented 8 years ago

Various events are sent when handling media that are embedded in HTML documents using the <audio> and <video> elements;

See: https://developer.mozilla.org/de/docs/Web/Guide/Events/Media_events

Identical to React's Media Events.

function render({ props, state }) {
  const {
    src
    } = props;

  const handleCanPlay => (event) => event.target.play();
  const handlePlaying => (event, component) {
    if(component.props.onPlaying) component.props.onPlaying(event);
  }

  return (
    <audio src={src} onCanPlay={handleCanPlay} onPlaying={handlePlaying}/>
  );
}
function onHitSoundPlaying(event) {
  // K. o.!!
}

<Audio src="npc/sounds/batman_hit_pow1.ogg" onPlaying={onHitSoundPlaying}/>
84564221 commented 8 years ago

Triggered a Circle-CI rebuild

anthonyshort commented 8 years ago

I'm going to check out these failing tests later today and see what's up. If you have time to look into it, go for it. As soon as we get them passing I'll merge these two PRs and do a release. Thanks again :D

timhudson commented 8 years ago

https://github.com/dekujs/deku/pull/295 should fix these failing tests