blob: 59b80dbecc7e0d791b256feba34ae727790055ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
const schedule = require('./schedule')
const self = {}
self._nodes = {
body: document.body
}
self._handleResize = function () {
// the table node may not exist before this function is called
const tableNode = document.querySelector('center > table')
// infact, it may not even exist when this function is called.
if (!tableNode) return
const tableWidth = tableNode.getBoundingClientRect().width
const tableGoalWidth = self._nodes.body.getBoundingClientRect().width * 0.9
const zoomFactor = tableGoalWidth / tableWidth
if (zoomFactor < 1) {
tableNode.style.zoom = `${zoomFactor}`
} else {
tableNode.style.zoom = `1`
}
}
schedule.on('load', self._handleResize)
window.addEventListener('resize', self._handleResize)
module.exports = self
|