mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(ui): render the imagery split dividers from a store
createImagerySplit keeps the divider's value, drag, keyboard, CSS position and scene split, and publishes its line to the imagery split store. ImagerySplitView, in the scene chrome, teleports each line to the body, so recent imagery and the Bhote Koshi event no longer build divider DOM.
This commit is contained in:
1 parent
0b8cb4f33f
commit
492b719f19
12 files changed
+402
-201
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { markRaw, shallowRef } from 'vue';
|
||||
|
||||
/**
|
||||
* The before/after imagery dividers on the page, as their view renders them.
|
||||
* Each split (src/ui/imagerySplit.js) publishes its line under its own key
|
||||
* and withdraws it when destroyed; the view sends pointer and keyboard input
|
||||
* back to that split's controls.
|
||||
*/
|
||||
export const useImagerySplitStore = defineStore('gev-imagery-split', () => {
|
||||
/** The dividers in creation order: `{key, view, controls}`. */
|
||||
const splits = shallowRef([]);
|
||||
|
||||
/**
|
||||
* Show or update one divider.
|
||||
* @param {number} key The split's own key.
|
||||
* @param {object} view A fresh presentation of its line.
|
||||
* @param {object} controls What the view calls for its input.
|
||||
*/
|
||||
function publish(key, view, controls) {
|
||||
const entry = markRaw({ key, view, controls });
|
||||
const index = splits.value.findIndex((split) => split.key === key);
|
||||
splits.value =
|
||||
index < 0
|
||||
? [...splits.value, entry]
|
||||
: splits.value.map((split, at) => (at === index ? entry : split));
|
||||
}
|
||||
|
||||
/** @param {number} key The split to remove. */
|
||||
function withdraw(key) {
|
||||
splits.value = splits.value.filter((split) => split.key !== key);
|
||||
}
|
||||
|
||||
return { splits, publish, withdraw };
|
||||
});
|
||||
Reference in new issue
Block a user