other changes

This commit is contained in:
Michael Murtaugh
2019-07-10 09:04:59 +02:00
parent 5ac253c712
commit 7e379b97c9
7 changed files with 447 additions and 238 deletions

70
dist/app.js vendored
View File

@@ -3156,6 +3156,12 @@ var app = (function (exports) {
var identity$1 = new Transform(1, 0, 0);
transform.prototype = Transform.prototype;
function transform(node) {
return node.__zoom || identity$1;
}
function nopropagation$1() {
event.stopImmediatePropagation();
}
@@ -5164,8 +5170,8 @@ var app = (function (exports) {
var width = 600,
height = 600;
this.zoom_level = opts.zoom || 1.5;
this.apiurl = opts.apiurl;
this.init_svg(opts.svg);
this.categorylabel = opts.categorylabel || "Category";
this.symbols_src = opts.symbols;
this.categorydiv = select(opts.categorydiv);
@@ -5178,6 +5184,7 @@ var app = (function (exports) {
// this.net = new ForceNet({});
// this.net.on("nodeclick", this.nodeclick.bind(this));
this.svg = null;
this.init_svg(opts.svg);
this.historylinks = {};
this.links = null;
this.highlight_category = null;
@@ -5263,9 +5270,9 @@ var app = (function (exports) {
this.rect = this.svg.append("rect")
.attr("width", 1000)
.attr("height", 1000)
.style("fill", "none")
.style("pointer-events", "all")
.call(this.zoom);
.style("fill", "none");
// .style("pointer-events", "all")
// .call(this.zoom);
this.content = this.svg.append("g")
.attr("id", "content"),
this.linksg = this.content.append("g")
@@ -5354,11 +5361,17 @@ var app = (function (exports) {
this.categorydiv
.selectAll("div.cat")
.classed("highlight", d=> d.page ? d.page.highlight : false);
var data = {nodes: this.wiki.get_nodes(), links: values(this.all_links_by_key)};
var data = {nodes: this.get_nodes(), links: values(this.all_links_by_key)};
this.update_node_counts();
this.update_graph(data);
}
get_nodes () {
var nodes = this.wiki.get_nodes();
nodes = nodes.filter(d => d.linked || d.active || d.active2 || d.highlight);
return nodes;
}
async set_active_page (page) {
console.log("wikimap: set_active_page:", page.title);
if (page === this.active_page) {
@@ -5403,7 +5416,7 @@ var app = (function (exports) {
// return;
} else if (page.ns !== 0) {
console.log("SPECIAL PAGE", page);
} else {
// LOAD/ENSURE PAGE LINKS
var links_out = await page.get_links();
@@ -5420,15 +5433,17 @@ var app = (function (exports) {
});
}
this.active_page = page;
this.active_page.active = true;
this.linked_nodes_set_active(this.active_page, true);
setTimeout(() => {
this.centerOnItem(page, 1000);
}, 1000);
this.events.emit("page", this.active_page);
var data = {nodes: this.wiki.get_nodes(), links: values(this.all_links_by_key)};
var data = {nodes: this.get_nodes(), links: values(this.all_links_by_key)};
this.update_node_counts();
this.update_graph(data);
// this.update_nodes();
@@ -5623,7 +5638,44 @@ var app = (function (exports) {
this.simulation.alpha(0.5).restart();
}
centerOnItem(item, duration) {
var bounds = this.svg.node().getBoundingClientRect();
var curt = transform(this.rect.node());
console.log("centerOnItem", this.zoom_level, "item", item);
var zoom_level = this.zoom_level ? this.zoom_level : curt.k;
if (item && item.x !== undefined) {
var transform$1 = function () {
return identity$1
.translate(bounds.width / 2, bounds.height / 2)
.scale(zoom_level)
.translate(-item.x, -item.y);
};
if (duration) {
this.rect.transition().duration(duration).call(this.zoom.transform, transform$1);
} else {
this.rect.call(this.zoom.transform, transform$1);
}
} else {
console.log("NO ITEM");
var transform$1 = function () {
return identity$1
.scale(1);
};
this.rect.call(this.zoom.transform, transform$1);
}
}
do_zoom (f, transition) {
this.rect.call(this.zoom.scaleBy, f);
}
zoom_in () {
this.do_zoom(1.25);
}
zoom_out () {
this.do_zoom(1/1.25);
}
}
exports.Map = Map$2;