Commit fa80584d authored by Fred Chasen's avatar Fred Chasen
Browse files

Merge branch 'patch-1' into 'master'

fixed issue #129

Closes #129

See merge request !110
parents 0aa5fcd1 1f958f54
Pipeline #490 passed with stage
in 3 minutes and 49 seconds
......@@ -71,7 +71,7 @@ class Page {
let page = this.element;
// let pagebox = this.pagebox;
let index = pgnum+1;
let index = pgnum + 1;
let id = `page-${index}`;
......@@ -151,7 +151,7 @@ class Page {
let e;
for (var i = 0; i < entries.length; i++) {
e = entries[i];
if(e.dataset.ref === ref) {
if (e.dataset.ref === ref) {
return e;
}
}
......@@ -181,8 +181,8 @@ class Page {
}
// TODO: fall back to mutation observer?
this._onScroll = function() {
if(this.listening) {
this._onScroll = function () {
if (this.listening) {
this.element.scrollLeft = 0;
}
}.bind(this);
......@@ -205,30 +205,31 @@ class Page {
this.element.removeEventListener("underflow", this._checkOverflowAfterResize, false);
}
this.element &&this.element.removeEventListener("scroll", this._onScroll);
this.element && this.element.removeEventListener("scroll", this._onScroll);
}
addResizeObserver(contents) {
let wrapper = this.wrapper;
let prevHeight = wrapper.getBoundingClientRect().height;
this.ro = new ResizeObserver( entries => {
this.ro = new ResizeObserver(entries => {
if (!this.listening) {
return;
}
for (let entry of entries) {
const cr = entry.contentRect;
if (cr.height > prevHeight) {
this.checkOverflowAfterResize(contents);
prevHeight = wrapper.getBoundingClientRect().height;
} else if (cr.height < prevHeight ) { // TODO: calc line height && (prevHeight - cr.height) >= 22
this.checkUnderflowAfterResize(contents);
prevHeight = cr.height;
requestAnimationFrame(() => {
for (let entry of entries) {
const cr = entry.contentRect;
if (cr.height > prevHeight) {
this.checkOverflowAfterResize(contents);
prevHeight = wrapper.getBoundingClientRect().height;
} else if (cr.height < prevHeight) { // TODO: calc line height && (prevHeight - cr.height) >= 22
this.checkUnderflowAfterResize(contents);
prevHeight = cr.height;
}
}
}
});
});
this.ro.observe(wrapper);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment