aboutsummaryrefslogtreecommitdiff
path: root/src/client/javascript/zoom.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2017-09-13 16:28:53 +0200
committerNoah Loomans <noahloomans@gmail.com>2017-09-13 16:28:53 +0200
commit3fb86482404e11942cd83c3500a297a3991db0e4 (patch)
treec5e7261de72c2b7f871580784525d06d036a6219 /src/client/javascript/zoom.js
parent5aac32f72eca8c66e879583ce653d07bb3c7370f (diff)
Restructure project
Diffstat (limited to 'src/client/javascript/zoom.js')
-rw-r--r--src/client/javascript/zoom.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/client/javascript/zoom.js b/src/client/javascript/zoom.js
new file mode 100644
index 0000000..59b80db
--- /dev/null
+++ b/src/client/javascript/zoom.js
@@ -0,0 +1,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