Commit 55f7d884 authored by Fred Chasen's avatar Fred Chasen

Add eslint, fix chunker

parent 77aaeb27
module.exports = {
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"globals": {
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 9
},
"rules": {
"indent": [
"error",
"tab",
{ "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"warn",
"double"
],
"semi": [
"error",
"always"
],
"no-unused-vars" : ["warn"],
"no-console" : ["warn"],
"no-unused-vars": [
"error",
{ "vars": "all", "args": "none" }
],
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
"valid-jsdoc": ["warn"]
}
};
...@@ -4,12 +4,7 @@ import EventEmitter from "event-emitter"; ...@@ -4,12 +4,7 @@ import EventEmitter from "event-emitter";
import Hook from "../utils/hook"; import Hook from "../utils/hook";
import Queue from "../utils/queue"; import Queue from "../utils/queue";
import { import {
needsBreakBefore, requestIdleCallback
needsBreakAfter
} from "../utils/dom";
import {
requestIdleCallback,
defer
} from "../utils/utils"; } from "../utils/utils";
const MAX_PAGES = false; const MAX_PAGES = false;
...@@ -174,7 +169,7 @@ class Chunker { ...@@ -174,7 +169,7 @@ class Chunker {
let result; let result;
while (!done) { while (!done) {
result = await this.q.enqueue(async () => { return this.renderOnIdle(renderer) }); result = await this.q.enqueue(async () => { return this.renderOnIdle(renderer); });
done = result.done; done = result.done;
} }
...@@ -309,7 +304,8 @@ class Chunker { ...@@ -309,7 +304,8 @@ class Chunker {
let lastPage = this.pages[this.pages.length - 1]; let lastPage = this.pages[this.pages.length - 1];
// Create a new page from the template // Create a new page from the template
let page = new Page(this.pagesArea, this.pageTemplate, blank, this.hooks); let page = new Page(this.pagesArea, this.pageTemplate, blank, this.hooks);
let total = this.pages.push(page);
this.pages.push(page);
// Create the pages // Create the pages
page.create(undefined, lastPage && lastPage.element); page.create(undefined, lastPage && lastPage.element);
...@@ -397,7 +393,7 @@ class Chunker { ...@@ -397,7 +393,7 @@ class Chunker {
} }
set total(num) { set total(num) {
this.pagesArea.style.setProperty('--page-count', num); this.pagesArea.style.setProperty("--page-count", num);
this._total = num; this._total = num;
} }
...@@ -410,17 +406,17 @@ class Chunker { ...@@ -410,17 +406,17 @@ class Chunker {
}, (r) => { }, (r) => {
console.warn("Failed to preload font-family:", fontFace.family); console.warn("Failed to preload font-family:", fontFace.family);
return fontFace.family; return fontFace.family;
}) });
fontPromises.push(fontLoaded); fontPromises.push(fontLoaded);
} }
}); });
return Promise.all(fontPromises).catch((err) => { return Promise.all(fontPromises).catch((err) => {
console.warn(err) console.warn(err);
}) });
} }
destroy() { destroy() {
this.pagesArea.remove() this.pagesArea.remove();
this.pageTemplate.remove(); this.pageTemplate.remove();
} }
......
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