|
|
@ -13,6 +13,7 @@ let util = require('../../util'); |
|
|
|
class Canvas { |
|
|
|
constructor(body) { |
|
|
|
this.body = body; |
|
|
|
this.pixelRatio = 1; |
|
|
|
|
|
|
|
this.options = {}; |
|
|
|
this.defaultOptions = { |
|
|
@ -21,6 +22,7 @@ class Canvas { |
|
|
|
} |
|
|
|
util.extend(this.options, this.defaultOptions); |
|
|
|
|
|
|
|
// bind the events
|
|
|
|
this.body.emitter.once("resize", (obj) => { |
|
|
|
if (obj.width !== 0) { |
|
|
|
this.body.view.translation.x = obj.width * 0.5; |
|
|
@ -31,9 +33,8 @@ class Canvas { |
|
|
|
}); |
|
|
|
this.body.emitter.on("destroy", () => this.hammer.destroy()); |
|
|
|
|
|
|
|
// automatically adapt to a changing size of the browser.
|
|
|
|
window.onresize = () => {this.setSize(); this.body.emitter.emit("_redraw");}; |
|
|
|
|
|
|
|
this.pixelRatio = 1; |
|
|
|
} |
|
|
|
|
|
|
|
setOptions(options) { |
|
|
@ -42,6 +43,10 @@ class Canvas { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Create the HTML |
|
|
|
*/ |
|
|
|
create() { |
|
|
|
// remove all elements from the container element.
|
|
|
|
while (this.body.container.hasChildNodes()) { |
|
|
@ -52,7 +57,7 @@ class Canvas { |
|
|
|
this.frame.className = 'vis network-frame'; |
|
|
|
this.frame.style.position = 'relative'; |
|
|
|
this.frame.style.overflow = 'hidden'; |
|
|
|
this.frame.tabIndex = 900; |
|
|
|
this.frame.tabIndex = 900; // tab index is required for keycharm to bind keystrokes to the div instead of the window
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|