Добавил onResize
This commit is contained in:
@@ -37,6 +37,10 @@ class TextPage extends Vue {
|
|||||||
this.debouncedEmitPosChange = _.debounce((newValue) => {
|
this.debouncedEmitPosChange = _.debounce((newValue) => {
|
||||||
this.$emit('book-pos-changed', {bookPos: newValue});
|
this.$emit('book-pos-changed', {bookPos: newValue});
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
this.onResize();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -51,6 +55,16 @@ class TextPage extends Vue {
|
|||||||
this.lineHeight = this.fontSize + this.lineInterval;
|
this.lineHeight = this.fontSize + this.lineInterval;
|
||||||
this.pageLineCount = Math.floor(this.canvas.height/this.lineHeight);
|
this.pageLineCount = Math.floor(this.canvas.height/this.lineHeight);
|
||||||
this.w = this.canvas.width - 2*this.indent;
|
this.w = this.canvas.width - 2*this.indent;
|
||||||
|
|
||||||
|
if (this.parsed) {
|
||||||
|
this.parsed.p = this.p;
|
||||||
|
this.parsed.w = this.w;// px, ширина текста
|
||||||
|
this.parsed.font = this.font;
|
||||||
|
this.measureText = (text, style) => {// eslint-disable-line no-unused-vars
|
||||||
|
return this.context.measureText(text).width;
|
||||||
|
};
|
||||||
|
this.parsed.measureText = this.measureText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showBook() {
|
showBook() {
|
||||||
@@ -62,7 +76,6 @@ class TextPage extends Vue {
|
|||||||
|
|
||||||
this.linesUp = null;
|
this.linesUp = null;
|
||||||
this.linesDown = null;
|
this.linesDown = null;
|
||||||
this.pageLineCount = 0;
|
|
||||||
|
|
||||||
//draw props
|
//draw props
|
||||||
this.textColor = 'black';
|
this.textColor = 'black';
|
||||||
@@ -96,22 +109,20 @@ class TextPage extends Vue {
|
|||||||
this.fb2.bookTitle
|
this.fb2.bookTitle
|
||||||
]).join(' '));
|
]).join(' '));
|
||||||
|
|
||||||
this.calcDrawProps();
|
|
||||||
const parsed = this.book.parsed;
|
const parsed = this.book.parsed;
|
||||||
parsed.p = this.p;
|
|
||||||
parsed.w = this.w;// px, ширина текста
|
|
||||||
parsed.font = this.font;
|
|
||||||
parsed.measureText = (text, style) => {// eslint-disable-line no-unused-vars
|
|
||||||
return this.context.measureText(text).width;
|
|
||||||
};
|
|
||||||
this.measureText = parsed.measureText;
|
|
||||||
|
|
||||||
this.parsed = parsed;
|
this.parsed = parsed;
|
||||||
|
this.calcDrawProps();
|
||||||
|
|
||||||
this.drawPage();
|
this.drawPage();
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onResize() {
|
||||||
|
this.calcDrawProps();
|
||||||
|
this.drawPage();
|
||||||
|
}
|
||||||
|
|
||||||
get font() {
|
get font() {
|
||||||
return `${this.fontStyle} ${this.fontSize}px ${this.fontName}`;
|
return `${this.fontStyle} ${this.fontSize}px ${this.fontName}`;
|
||||||
}
|
}
|
||||||
@@ -241,19 +252,14 @@ class TextPage extends Vue {
|
|||||||
<style scoped>
|
<style scoped>
|
||||||
.main {
|
.main {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
margin: 0;
|
||||||
flex-direction: column;
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.canvas {
|
.canvas {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user