mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
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.
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
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 };
|
|
});
|