1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-03 14:59:18 +02:00

awesome hack to make the mouse interaction working 😏

This commit is contained in:
Do Park 2023-10-28 14:35:38 -07:00
parent 83b0f7755f
commit 583577b72a
7 changed files with 453 additions and 38 deletions

View file

@ -31,7 +31,7 @@ class Annotations {
* @param {object} styles CSS styles to assign to annotation
* @returns {Annotation} annotation
*/
add (type, cfiRange, data, cb, className, styles) {
add (type, cfiRange, data, cb, className, styles, cbOptions) {
let hash = encodeURI(cfiRange + type);
let cfi = new EpubCFI(cfiRange);
let sectionIndex = cfi.spinePos;
@ -42,7 +42,8 @@ class Annotations {
sectionIndex,
cb,
className,
styles
styles,
cbOptions,
});
this._annotations[hash] = annotation;
@ -116,8 +117,8 @@ class Annotations {
* @param {string} className CSS class to assign to annotation
* @param {object} styles CSS styles to assign to annotation
*/
highlight (cfiRange, data, cb, className, styles) {
return this.add("highlight", cfiRange, data, cb, className, styles);
highlight (cfiRange, data, cb, className, styles, cbOptions) {
return this.add("highlight", cfiRange, data, cb, className, styles, cbOptions);
}
/**
@ -221,7 +222,8 @@ class Annotation {
sectionIndex,
cb,
className,
styles
styles,
cbOptions,
}) {
this.type = type;
this.cfiRange = cfiRange;
@ -231,6 +233,7 @@ class Annotation {
this.cb = cb;
this.className = className;
this.styles = styles;
this.cbOptions = cbOptions;
}
/**
@ -246,11 +249,11 @@ class Annotation {
* @param {View} view
*/
attach (view) {
let {cfiRange, data, type, mark, cb, className, styles} = this;
let {cfiRange, data, type, mark, cb, cbOptions, className, styles} = this;
let result;
if (type === "highlight") {
result = view.highlight(cfiRange, data, cb, className, styles);
result = view.highlight(cfiRange, data, cb, className, styles, cbOptions);
} else if (type === "underline") {
result = view.underline(cfiRange, data, cb, className, styles);
} else if (type === "mark") {