Skip to content

Commit

Permalink
feat: add touch support
Browse files Browse the repository at this point in the history
  • Loading branch information
alxpez committed Jan 28, 2019
1 parent 41a4706 commit d0e2288
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dist/ivid.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/TODO.md
Expand Up @@ -5,5 +5,5 @@
- [x] iVid `model`
- [x] iVid `styles`

- [ ] Add touch support
- [x] Add touch support
- [ ] Add tracks support (subs, audio)
2 changes: 1 addition & 1 deletion sandbox/lib/ivid.min.js

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions src/index.js
Expand Up @@ -53,12 +53,14 @@ class Ivid extends HTMLElement {
}
},
onPlayClick: {
value: () => {
value: (event) => {
event.preventDefault();
this.togglePlay();
}
},
onVolumeClick: {
value: () => {
value: (event) => {
event.preventDefault();
this.toggleMute();
}
},
Expand Down Expand Up @@ -86,7 +88,8 @@ class Ivid extends HTMLElement {
}
},
onVideoClick: {
value: () => {
value: (event) => {
event.preventDefault();
this.togglePlay();
this.onShowControls();
}
Expand Down Expand Up @@ -123,7 +126,6 @@ class Ivid extends HTMLElement {

if (videoTpl.duration - videoTpl.currentTime <= 1) {
let fallback = null;

if (s.next)
fallback = s.next;
else if (videoItem.options)
Expand All @@ -145,7 +147,8 @@ class Ivid extends HTMLElement {
}
},
onChoiceSelected: {
value: (choiceUid) => {
value: (choiceUid, event) => {
if (event) event.preventDefault();
let choices = this.state.choicesTemplate;

this.setAttribute('next', choiceUid);
Expand Down
4 changes: 2 additions & 2 deletions src/templates/choices.js
Expand Up @@ -40,8 +40,8 @@ const renderChoicesTemplate = (choicesTpl, videoItem, choiceClickCallback) => {
button.setAttribute('class', 'ivid__choice-button');
button.id = choiceUid;
button.innerHTML = choices[choiceUid];
button.ontouchstart = () => choiceClickCallback(choiceUid);
button.onclick = () => choiceClickCallback(choiceUid);
button.ontouchstart = (e) => choiceClickCallback(choiceUid, e);
button.onclick = (e) => choiceClickCallback(choiceUid, e);

choicesTpl.appendChild(button);
}
Expand Down
8 changes: 4 additions & 4 deletions src/templates/controls.js
Expand Up @@ -136,13 +136,13 @@ const setupControlsTemplate = () => {
controls.progress.progressWrapper.ontouchstart = (e) => progressClickCallback(e);
controls.progress.progressWrapper.onclick = (e) => progressClickCallback(e);

controls.playButton.ontouchstart = () => playClickCallback();
controls.playButton.onclick = () => playClickCallback();
controls.playButton.ontouchstart = (e) => playClickCallback(e);
controls.playButton.onclick = (e) => playClickCallback(e);

controls.volume.volumeWrapper.onmouseover = () => volumeHoverCallback();
controls.volume.volumeWrapper.onmouseleave = () => volumeLeaveCallback();
controls.volume.volumeButton.ontouchstart = () => volumeClickCallback();
controls.volume.volumeButton.onclick = () => volumeClickCallback();
controls.volume.volumeButton.ontouchstart = (e) => volumeClickCallback(e);
controls.volume.volumeButton.onclick = (e) => volumeClickCallback(e);

controls.volume.volumeSlider.oninput = (e) => volumeChangeCallback(e);
controls.volume.volumeSlider.onchange = (e) => volumeChangeCallback(e);
Expand Down

0 comments on commit d0e2288

Please sign in to comment.