summaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2016-04-02 10:58:55 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2016-04-02 10:58:55 +0200
commita91c4670de5516750a482860c73ca8ac835e6831 (patch)
tree6413df348341b8105a2d43c0fc1911e06f785cbe /code
parentbc373a453948815b2707e6ae67e7bb40e169bec6 (diff)
downloadvortrag-knn-a91c4670de5516750a482860c73ca8ac835e6831.tar.gz
vortrag-knn-a91c4670de5516750a482860c73ca8ac835e6831.zip
that was close - add weightsVisWrapperWrapper and fix reloading page inits
Diffstat (limited to 'code')
-rw-r--r--code/weightviswrapper.js39
1 files changed, 33 insertions, 6 deletions
diff --git a/code/weightviswrapper.js b/code/weightviswrapper.js
index 74ae622..aa18ae1 100644
--- a/code/weightviswrapper.js
+++ b/code/weightviswrapper.js
@@ -9,6 +9,7 @@ var WeightVisWrapper = (function() {
this.svg = this.svgContainer.append("svg");
this.netVisualizer = new NetVisualizer(this.svg);
this.resizeHooks = [];
+ this.readyHooks = [];
this.ready = false;
this.svgContainer
@@ -18,7 +19,7 @@ var WeightVisWrapper = (function() {
.style("width", "100%");
this.spinner = this.container.append("div")
- .attr("class", "mdl-spinner mdl-js-spinner mdl-spinner--single-color is-active visContainer")
+ .attr("class", "mdl-spinner mdl-js-spinner mdl-spinner--single-color is-active spinner")
.style("position", "absolute")
.style("left", "50%")
.style("top", "50%");
@@ -96,10 +97,19 @@ var WeightVisWrapper = (function() {
});
self.ready = true;
callback();
+ self.readyHooks.forEach(function(hook) { hook(); });
console.log("ready"); // DEBUG
});
};
+ WeightVisWrapper.prototype.afterLoad = function(cb) {
+ if (!this.ready) {
+ this.readyHooks.push(cb);
+ } else {
+ cb();
+ }
+ };
+
var attrFontSize = 20;
WeightVisWrapper.prototype.placeAttributes = function() {
var inputNodes = this.svg.selectAll(".layer-1")[0];
@@ -113,14 +123,13 @@ var WeightVisWrapper = (function() {
};
WeightVisWrapper.prototype.addPlaceholder = function(el) {
- el.node().parentNode.appendChild(this.spinner.node().cloneNode(true));
- el.remove();
+ el.appendChild(this.spinner.node().cloneNode(true));
};
WeightVisWrapper.prototype.openIn = function(el) {
- el.node().parentNode.appendChild(this.svgContainer.node());
- el.node().parentNode.appendChild(this.controlContainer.node());
- el.remove();
+ d3.select(el).select(".spinner").remove();
+ el.appendChild(this.svgContainer.node());
+ el.appendChild(this.controlContainer.node());
this.reposition();
};
@@ -151,3 +160,21 @@ var WeightVisWrapper = (function() {
return WeightVisWrapper;
})();
+
+/* helps with impress.js' stepenter/stepleave events */
+var VisIntegrater = (function() {
+ function VisIntegrater(enterCb, leaveCb) {
+ var self = this;
+ this.slide = document.currentScript.parentElement;
+ this.container = d3.select(this.slide).select(".visContainer");
+ console.log(this.slide);
+ this.slide.addEventListener("impress:stepenter", function() {
+ enterCb(self.slide);
+ });
+ this.slide.addEventListener("impress:stepleave", function() {
+ leaveCb(self.slide);
+ });
+ }
+
+ return VisIntegrater;
+})();