Skip to content

Commit

Permalink
reload with follow: zenith
Browse files Browse the repository at this point in the history
  • Loading branch information
ofrohn committed May 26, 2020
1 parent 0ec573c commit 263241b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 20 deletions.
18 changes: 11 additions & 7 deletions celestial.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2015-2020 Olaf Frohn https://github.com/ofrohn, see LICENSE
!(function() {
var Celestial = {
version: '0.7.14',
version: '0.7.15',
container: null,
data: []
};
Expand Down Expand Up @@ -920,12 +920,16 @@ Celestial.display = function(config) {
return cfg.width;
};
this.reload = function(config) {
var ctr;
//if (!config || !has(config, "transform")) return;
//cfg.transform = config.transform;
if (config) Object.assign(cfg, settings.set(config));
if (cfg.follow === "center" && has(cfg, "center")) {
mapProjection.rotate(getAngles(cfg.center));
}
ctr = getAngles(cfg.center);
} else if (cfg.follow === "zenith") {
ctr = getAngles(Celestial.zenith());
}
if (ctr) mapProjection.rotate(ctr);
container.selectAll("*").remove();
load();
};
Expand Down Expand Up @@ -3284,6 +3288,8 @@ function geo(cfg) {
zenith[2] = 0;
if (config.follow === "zenith") {
Celestial.rotate({center:zenith});
} else {
Celestial.redraw();
}
}
}
Expand All @@ -3301,17 +3307,15 @@ function geo(cfg) {
if (dtpick.isVisible()) dtpick.hide();
date.setTime(dt.valueOf());
$("datetime").value = dateFormat(dt, zone);
if (config.follow === "zenith") go();
else Celestial.redraw();
go();
};
Celestial.timezone = function (tz) {
if (!tz) return zone;
zone = tz || zone;
Object.assign(config, settings.set());
if (dtpick.isVisible()) dtpick.hide();
$("datetime").value = dateFormat(date, zone);
if (config.follow === "zenith") go();
else Celestial.redraw();
go();
};
Celestial.position = function () { return geopos; };
Celestial.location = function (loc) {
Expand Down
6 changes: 3 additions & 3 deletions celestial.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/planets-animation.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
form: true,
formFields: {"location": true, "general": false, "stars": false, "dsos": false, "constellations": false, "lines": false, "other": true},
advanced: false,
//follow: "center",
follow: "center",
projection: "orthographic",
datapath: "https://ofrohn.github.io/data/",
planets: { show: true },
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d3-celestial",
"version": "0.7.14",
"version": "0.7.15",
"description": "A star map with D3.js",
"main": "celestial.js",
"directories": {
Expand Down
10 changes: 7 additions & 3 deletions src/celestial.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global module, require, settings, bvcolor, projections, projectionTween, poles, eulerAngles, euler, getAngles, transformDeg, getData, getPlanets, getPlanet, listConstellations, getConstellationList, getMwbackground, getGridValues, Canvas, halfπ, $, px, Round, has, hasCallback, isArray, isNumber, arrayfy, form, geo, fldEnable, setCenter, interpolateAngle, formats */
var Celestial = {
version: '0.7.14',
version: '0.7.15',
container: null,
data: []
};
Expand Down Expand Up @@ -919,12 +919,16 @@ Celestial.display = function(config) {
return cfg.width;
};
this.reload = function(config) {
var ctr;
//if (!config || !has(config, "transform")) return;
//cfg.transform = config.transform;
if (config) Object.assign(cfg, settings.set(config));
if (cfg.follow === "center" && has(cfg, "center")) {
mapProjection.rotate(getAngles(cfg.center));
}
ctr = getAngles(cfg.center);
} else if (cfg.follow === "zenith") {
ctr = getAngles(Celestial.zenith());
}
if (ctr) mapProjection.rotate(ctr);
container.selectAll("*").remove();
load();
};
Expand Down
8 changes: 4 additions & 4 deletions src/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ function geo(cfg) {
zenith[2] = 0;
if (config.follow === "zenith") {
Celestial.rotate({center:zenith});
} else {
Celestial.redraw();
}
}
}
Expand All @@ -196,17 +198,15 @@ function geo(cfg) {
if (dtpick.isVisible()) dtpick.hide();
date.setTime(dt.valueOf());
$("datetime").value = dateFormat(dt, zone);
if (config.follow === "zenith") go();
else Celestial.redraw();
go();
};
Celestial.timezone = function (tz) {
if (!tz) return zone;
zone = tz || zone;
Object.assign(config, settings.set());
if (dtpick.isVisible()) dtpick.hide();
$("datetime").value = dateFormat(date, zone);
if (config.follow === "zenith") go();
else Celestial.redraw();
go();
};
Celestial.position = function () { return geopos; };
Celestial.location = function (loc) {
Expand Down

0 comments on commit 263241b

Please sign in to comment.