Skip to content

Commit

Permalink
Merge pull request #57 from hahow/fix/near-end-lecture-note-and-same-…
Browse files Browse the repository at this point in the history
…time-edit

fix: near end lecture note can not click
  • Loading branch information
raccoon-lee authored Aug 22, 2018
2 parents 9e0600f + 5c96083 commit b31ca34
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dist/hahow-plyr.css

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion dist/plyr.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plyr.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plyr.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plyr.min.js.map

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion dist/plyr.polyfilled.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plyr.polyfilled.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plyr.polyfilled.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plyr.polyfilled.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hahow-plyr",
"version": "1.3.1",
"version": "1.3.2",
"description":
"A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
"homepage": "https://plyr.io",
Expand Down
19 changes: 16 additions & 3 deletions src/js/plugins/lectureNote.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ export default class LectureNote {
const time = Math.round(this.player.currentTime);
const note = this.getSameTimeLectureNote(time);
if (note) {

const lectureNoteContainer = getElement.call(this.player, `.lecture-note[data-id="${ note._id }"]`);
if (lectureNoteContainer) {
const contentContianer = lectureNoteContainer.querySelector('lecture-note__content-container ');
const contentContianer = lectureNoteContainer.querySelector('.lecture-note__content-container');
if (contentContianer) {
const clickEvent = new Event('click');
contentContianer.dispatchEvent(clickEvent);
Expand Down Expand Up @@ -353,6 +352,13 @@ export default class LectureNote {
cancelTimeout = null;
}
toggleClass(contentContainer, 'lecture-note__content-container--show', true);
const container = this.getContainer();
const leftLimit = ((container.offsetWidth - 200) / container.offsetWidth) * 100 || 0;
if (percent > leftLimit) {
toggleClass(contentContainer, 'lecture-note__content-container--near-end', true);
} else {
toggleClass(contentContainer, 'lecture-note__content-container--near-end', false);
}
e.preventDefault();
});

Expand All @@ -370,6 +376,13 @@ export default class LectureNote {
cancelTimeout = null;
}
toggleClass(contentContainer, 'lecture-note__content-container--show', true);
const container = this.getContainer();
const leftLimit = ((container.offsetWidth - 200) / container.offsetWidth) * 100 || 0;
if (percent > leftLimit) {
toggleClass(contentContainer, 'lecture-note__content-container--near-end', true);
} else {
toggleClass(contentContainer, 'lecture-note__content-container--near-end', false);
}
e.preventDefault();
});

Expand All @@ -381,7 +394,7 @@ export default class LectureNote {
e.preventDefault();
});

lectureNoteContainer.style.left = `calc(${(lectureNote.time / duration) * 100 || 0}%)`;
lectureNoteContainer.style.left = `calc(${percent}%)`;
return lectureNoteContainer;
}
}
5 changes: 5 additions & 0 deletions src/sass/hahow-plyr.scss
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ $plyr-font-size-captions-small: 24px;
display: flex;
}

.lecture-note__content-container.lecture-note__content-container--near-end {
left: auto;
right: 0;
}

.lecture-note__content-show-text {
color: #000;
margin: 2px 5px;
Expand Down

0 comments on commit b31ca34

Please sign in to comment.