@cosmicds/vue-toolkit 0.2.0 → 0.4.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.
- package/README.md +20 -1
- package/dist/index.common.js +32528 -31853
- package/dist/index.umd.js +32527 -31844
- package/dist/index.umd.min.js +6 -4
- package/dist/src/background.d.ts +4 -0
- package/dist/src/components/CreditLogos.vue.d.ts +27 -2
- package/dist/src/components/FundingAcknowledgement.vue.d.ts +21 -0
- package/dist/src/components/Gallery.vue.d.ts +79 -2
- package/dist/src/components/GeolocationButton.vue.d.ts +132 -0
- package/dist/src/components/IconButton.vue.d.ts +130 -2
- package/dist/src/components/LocationSelector.vue.d.ts +139 -2
- package/dist/src/components/WwtHud.vue.d.ts +69 -0
- package/dist/src/composables.d.ts +25 -0
- package/dist/src/geolocation.d.ts +31 -0
- package/dist/src/index.d.ts +11 -8
- package/dist/src/keyboard.d.ts +35 -2
- package/dist/src/mapbox.d.ts +98 -0
- package/dist/src/stories/CreditLogos.stories.d.ts +6 -0
- package/dist/src/stories/FundingAcknowledgement.stories.d.ts +6 -0
- package/dist/src/stories/Gallery.stories.d.ts +6 -0
- package/dist/src/stories/IconButton.stories.d.ts +6 -0
- package/dist/src/stories/LocationSelector.stories.d.ts +6 -0
- package/dist/src/stories/WwtHud.stories.d.ts +6 -0
- package/dist/src/types.d.ts +241 -0
- package/dist/src/utils.d.ts +27 -1
- package/dist/src/wwt-utils.d.ts +11 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -4
- package/src/background.ts +4 -0
- package/src/composables.ts +69 -0
- package/src/geolocation.ts +122 -0
- package/src/index.ts +23 -15
- package/src/keyboard.ts +39 -5
- package/src/mapbox.ts +227 -0
- package/src/types.ts +271 -0
- package/src/utils.ts +54 -1
- package/src/wwt-utils.ts +57 -0
- package/dist/index.common.js.map +0 -1
- package/dist/index.umd.js.map +0 -1
- package/dist/index.umd.min.js.map +0 -1
- package/dist/src/components/DefaultMiniCredits.vue.d.ts +0 -3
- package/dist/src/components/FundingAcknowledgment.vue.d.ts +0 -3
- package/dist/src/components/MiniDSBase.d.ts +0 -373
- package/dist/src/components/wwtHUD.vue.d.ts +0 -3
package/src/wwt-utils.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { engineStore } from "@wwtelescope/engine-pinia";
|
|
2
|
+
import { KeyboardControlSettings } from "./keyboard";
|
|
3
|
+
type WWTEngineStore = ReturnType<typeof engineStore>;
|
|
4
|
+
|
|
5
|
+
function doZoom(store: WWTEngineStore, zoomIn: boolean) {
|
|
6
|
+
const factor = zoomIn ? 1 / 1.3 : 1.3;
|
|
7
|
+
store.zoom(factor);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function doMove(store: WWTEngineStore, x: number, y: number) {
|
|
11
|
+
store.move({ x, y });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A composable that sets up WWT keyboard controls.
|
|
16
|
+
* @param store The WWT engine's Pinia store
|
|
17
|
+
* @param element The element on which to attach the keyboard listeners. Uses the browser window if none is given
|
|
18
|
+
* @returns The `KeyboardControlSettings` instance that was used to create the listeners
|
|
19
|
+
*/
|
|
20
|
+
export function useWWTKeyboardControls(store: WWTEngineStore, element?: Window | HTMLElement): KeyboardControlSettings {
|
|
21
|
+
const root = element || window;
|
|
22
|
+
const kcs = new KeyboardControlSettings({});
|
|
23
|
+
root.addEventListener(
|
|
24
|
+
"keydown",
|
|
25
|
+
kcs.makeListener("zoomIn", () => doZoom(store, true)) as EventListener
|
|
26
|
+
);
|
|
27
|
+
root.addEventListener(
|
|
28
|
+
"keydown",
|
|
29
|
+
kcs.makeListener("zoomOut", () => doZoom(store, false)) as EventListener
|
|
30
|
+
);
|
|
31
|
+
root.addEventListener(
|
|
32
|
+
"keydown",
|
|
33
|
+
kcs.makeListener("moveUp", () =>
|
|
34
|
+
doMove(store, 0, kcs.moveAmount)
|
|
35
|
+
) as EventListener
|
|
36
|
+
);
|
|
37
|
+
root.addEventListener(
|
|
38
|
+
"keydown",
|
|
39
|
+
kcs.makeListener("moveDown", () =>
|
|
40
|
+
doMove(store, 0, -kcs.moveAmount)
|
|
41
|
+
) as EventListener
|
|
42
|
+
);
|
|
43
|
+
root.addEventListener(
|
|
44
|
+
"keydown",
|
|
45
|
+
kcs.makeListener("moveLeft", () =>
|
|
46
|
+
doMove(store, kcs.moveAmount, 0)
|
|
47
|
+
) as EventListener
|
|
48
|
+
);
|
|
49
|
+
root.addEventListener(
|
|
50
|
+
"keydown",
|
|
51
|
+
kcs.makeListener("moveRight", () =>
|
|
52
|
+
doMove(store, -kcs.moveAmount, 0)
|
|
53
|
+
) as EventListener
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return kcs;
|
|
57
|
+
}
|