]> git.r.bdr.sh - rbdr/heart/blame_incremental - js/app.js
Add mouse following
[rbdr/heart] / js / app.js
... / ...
CommitLineData
1'use strict';
2
3// Sets up the application
4
5((window) => {
6
7 const internals = {};
8
9 internals.onLoad = () => {
10
11 const mainElement = window.document.getElementById('heart-app-entry-point');
12 const heartRenderer = new HeartRenderer();
13
14 heartRenderer.render(mainElement);
15 heartRenderer.activate();
16
17 window.addEventListener('resize', heartRenderer.resize.bind(heartRenderer));
18 window.addEventListener('blur', heartRenderer.stopFollowingMouse.bind(heartRenderer));
19 window.addEventListener('focus', heartRenderer.startFollowingMouse.bind(heartRenderer));
20
21 /**
22 * Exported global object. This will contain the instance of the heart
23 * renderer being used. It is set up on load.
24 *
25 * @name App
26 * @type Object
27 * @property {HeartRenderer} heartRenderer The instance of the heart renderer being used.
28 */
29 window.App = {
30 heartRenderer
31 };
32 };
33
34 window.addEventListener('load', internals.onLoad);
35})(window);