layerchart 0.14.2 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script context="module">import { getContext, setContext } from 'svelte';
|
|
1
|
+
<script context="module">import { getContext, setContext, tick } from 'svelte';
|
|
2
2
|
import { writable } from 'svelte/store';
|
|
3
3
|
import { geoMercator } from 'd3-geo';
|
|
4
4
|
export const geoContextKey = {};
|
|
@@ -25,20 +25,35 @@ export let center = undefined;
|
|
|
25
25
|
const geo = writable(projection());
|
|
26
26
|
setGeoContext(geo);
|
|
27
27
|
$: fitSizeRange = (fixedAspectRatio ? [100, 100 / fixedAspectRatio] : [$width, $height]);
|
|
28
|
+
$: console.log({ $width, $height });
|
|
29
|
+
let initialized = false;
|
|
28
30
|
$: {
|
|
31
|
+
console.log('update', { fitGeojson, translate, scale });
|
|
29
32
|
const _projection = projection();
|
|
30
|
-
if (fitGeojson && 'fitSize' in _projection) {
|
|
31
|
-
_projection.fitSize(fitSizeRange, fitGeojson);
|
|
32
|
-
}
|
|
33
33
|
if (scale && 'scale' in _projection) {
|
|
34
34
|
_projection.scale(scale);
|
|
35
35
|
}
|
|
36
|
-
if (rotate && 'rotate' in _projection) {
|
|
37
|
-
_projection.rotate([rotate.yaw, rotate.pitch, rotate.roll]);
|
|
38
|
-
}
|
|
39
36
|
if (translate && 'translate' in _projection) {
|
|
40
37
|
_projection.translate(translate);
|
|
41
38
|
}
|
|
39
|
+
// Apply before `rotate` but after `translate` / `scale`
|
|
40
|
+
if (fitGeojson && 'fitSize' in _projection) {
|
|
41
|
+
if (!initialized || (translate == undefined && scale == undefined)) {
|
|
42
|
+
console.log({ fitGeojson, $width, $height });
|
|
43
|
+
console.log('translate/scale before', {
|
|
44
|
+
translate: _projection.translate(),
|
|
45
|
+
scale: _projection.scale()
|
|
46
|
+
});
|
|
47
|
+
_projection.fitSize(fitSizeRange, fitGeojson);
|
|
48
|
+
console.log('translate/scale after', {
|
|
49
|
+
translate: _projection.translate(),
|
|
50
|
+
scale: _projection.scale()
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (rotate && 'rotate' in _projection) {
|
|
55
|
+
_projection.rotate([rotate.yaw, rotate.pitch, rotate.roll]);
|
|
56
|
+
}
|
|
42
57
|
if (center && 'center' in _projection) {
|
|
43
58
|
_projection.center(center);
|
|
44
59
|
}
|
|
@@ -48,6 +63,9 @@ $: {
|
|
|
48
63
|
if (clipExtent && 'clipExtent' in _projection) {
|
|
49
64
|
_projection.clipExtent(clipExtent);
|
|
50
65
|
}
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
initialized = true;
|
|
68
|
+
}, 3000);
|
|
51
69
|
geo.set(_projection);
|
|
52
70
|
}
|
|
53
71
|
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import { getContext, createEventDispatcher } from 'svelte';
|
|
1
|
+
<script>import { getContext, createEventDispatcher, onMount } from 'svelte';
|
|
2
2
|
import { motionStore } from '../stores/motionStore';
|
|
3
3
|
const { width, height, padding } = getContext('LayerCake');
|
|
4
4
|
export let mode = 'svg';
|
|
@@ -159,7 +159,13 @@ $: if (mode === 'svg') {
|
|
|
159
159
|
};
|
|
160
160
|
transform = `translate(${newTranslate.x},${newTranslate.y}) scale(${$scale})`;
|
|
161
161
|
}
|
|
162
|
+
let isMounted = false;
|
|
163
|
+
onMount(() => {
|
|
164
|
+
isMounted = true;
|
|
165
|
+
});
|
|
166
|
+
// $: if (isMounted) {
|
|
162
167
|
$: dispatch('zoom', { scale: $scale, translate: $translate });
|
|
168
|
+
// }
|
|
163
169
|
</script>
|
|
164
170
|
|
|
165
171
|
<g
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "techniq/layerchart",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.15.0",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "vite dev",
|
|
9
9
|
"build": "vite build",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@rollup/plugin-dsv": "^3.0.2",
|
|
20
|
-
"@sveltejs/adapter-vercel": "^2.4.
|
|
21
|
-
"@sveltejs/kit": "^1.
|
|
20
|
+
"@sveltejs/adapter-vercel": "^2.4.3",
|
|
21
|
+
"@sveltejs/kit": "^1.15.9",
|
|
22
22
|
"@sveltejs/package": "^2.0.2",
|
|
23
23
|
"@tailwindcss/typography": "^0.5.9",
|
|
24
24
|
"@types/d3-array": "^3.0.4",
|
|
@@ -36,26 +36,27 @@
|
|
|
36
36
|
"@types/topojson-client": "^3.1.1",
|
|
37
37
|
"autoprefixer": "^10.4.14",
|
|
38
38
|
"mdsvex": "^0.10.6",
|
|
39
|
-
"prettier": "^2.8.
|
|
40
|
-
"prettier-plugin-svelte": "^2.
|
|
39
|
+
"prettier": "^2.8.8",
|
|
40
|
+
"prettier-plugin-svelte": "^2.10.0",
|
|
41
41
|
"prism-themes": "^1.9.0",
|
|
42
42
|
"rehype-slug": "^5.1.0",
|
|
43
|
-
"svelte-check": "^3.
|
|
43
|
+
"svelte-check": "^3.2.0",
|
|
44
44
|
"svelte-preprocess": "^5.0.1",
|
|
45
|
-
"svelte2tsx": "^0.6.
|
|
46
|
-
"tailwindcss": "^3.2
|
|
45
|
+
"svelte2tsx": "^0.6.11",
|
|
46
|
+
"tailwindcss": "^3.3.2",
|
|
47
47
|
"tslib": "^2.5.0",
|
|
48
|
-
"typescript": "^5.0.
|
|
48
|
+
"typescript": "^5.0.4",
|
|
49
49
|
"unist-util-visit": "^4.1.2",
|
|
50
|
-
"us-atlas": "^3.0.
|
|
51
|
-
"vite": "^4.
|
|
50
|
+
"us-atlas": "^3.0.1",
|
|
51
|
+
"vite": "^4.3.3",
|
|
52
52
|
"vite-plugin-sveld": "^1.1.0"
|
|
53
53
|
},
|
|
54
54
|
"type": "module",
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@mdi/js": "^7.2.96",
|
|
57
|
+
"@vercel/analytics": "^1.0.0",
|
|
57
58
|
"d3-array": "^3.2.3",
|
|
58
|
-
"d3-delaunay": "^6.0.
|
|
59
|
+
"d3-delaunay": "^6.0.4",
|
|
59
60
|
"d3-dsv": "^3.0.1",
|
|
60
61
|
"d3-geo": "^3.1.0",
|
|
61
62
|
"d3-hierarchy": "^3.1.2",
|
|
@@ -69,10 +70,10 @@
|
|
|
69
70
|
"d3-shape": "^3.2.0",
|
|
70
71
|
"d3-tile": "^1.0.0",
|
|
71
72
|
"date-fns": "^2.29.3",
|
|
72
|
-
"layercake": "^7.
|
|
73
|
+
"layercake": "^7.4.0",
|
|
73
74
|
"lodash-es": "^4.17.21",
|
|
74
|
-
"svelte": "^3.
|
|
75
|
-
"svelte-ux": "^0.
|
|
75
|
+
"svelte": "^3.58.0",
|
|
76
|
+
"svelte-ux": "^0.31.0",
|
|
76
77
|
"topojson-client": "^3.1.0"
|
|
77
78
|
},
|
|
78
79
|
"main": "./dist/index.js",
|