1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-04 15:09:16 +02:00

Remove annotations also from _annotationsBySectionIndex.

Remove annotations also from _annotationsBySectionIndex.
This commit is contained in:
Bruno 2017-09-27 20:21:12 +02:00
parent d77fc06a2e
commit 21aff9f41c

View file

@ -81,6 +81,7 @@ class Annotations {
let views = this.rendition.views(); let views = this.rendition.views();
views.each( (view) => { views.each( (view) => {
this._removeFromAnnotationBySectionIndex(annotation.sectionIndex, hash);
if (annotation.sectionIndex === view.index) { if (annotation.sectionIndex === view.index) {
annotation.detach(view); annotation.detach(view);
} }
@ -90,6 +91,14 @@ class Annotations {
} }
} }
_removeFromAnnotationBySectionIndex (sectionIndex, hash) {
this._annotationsBySectionIndex[sectionIndex] = this._annotationsAt(sectionIndex).filter(h => h !== hash);
}
_annotationsAt (index) {
return this._annotationsBySectionIndex[index];
}
highlight (cfiRange, data, cb) { highlight (cfiRange, data, cb) {
this.add("highlight", cfiRange, data, cb); this.add("highlight", cfiRange, data, cb);
} }