Skip to content

Commit

Permalink
Attached (#43)
Browse files Browse the repository at this point in the history
* feat: add progress in vue playground

* feat: add 600 delay

* feat: check attached and isMounted
  • Loading branch information
meloalright authored Aug 17, 2024
1 parent 528631f commit 7d9d251
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion vue-skia-framework/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const VSKNode = (name: string) => {
instance._ssw_id = (
parent as ComponentInternalInstanceWithSoftSkiaWASM
)._ssw_id;
instance._ssw_attached = true;

instance._ssw_grouped = (child) => {
core.setAttrBySerde(instance._ssw_id, {
Expand Down Expand Up @@ -103,6 +104,7 @@ const VSKNode = (name: string) => {
}
const core = root.ssw;
instance._ssw_id = SelfIncreaseCount.count;
instance._ssw_attached = true;
var parent = instance.parent;
while (!('_ssw_id' in parent)) {
parent = parent.parent;
Expand Down Expand Up @@ -208,7 +210,10 @@ const VSKNode = (name: string) => {
while (!('_ssw_id' in parent)) {
parent = parent.parent;
}
core.removeChildFromContainer(child_id, (parent as ComponentInternalInstanceWithSoftSkiaWASM)._ssw_id)
instance._ssw_attached = false;
if ((parent as ComponentInternalInstanceWithSoftSkiaWASM)._ssw_attached && parent.isMounted) {
core.removeChildFromContainer(child_id, (parent as ComponentInternalInstanceWithSoftSkiaWASM)._ssw_id)
}
});

return () => h(name, {}, slots.default?.())
Expand Down
1 change: 1 addition & 0 deletions vue-skia-framework/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SoftSkiaWASM } from '../soft-skia-wasm/pkg/';
export type ComponentInternalInstanceWithSoftSkiaWASM = ComponentInternalInstance & {
ssw: SoftSkiaWASM;
_ssw_id: number;
_ssw_attached: boolean;
_ssw_grouped?: (instance: ComponentInternalInstanceWithSoftSkiaWASM) => void;
_ssw_batchDraw?: () => void;
}
Expand Down

0 comments on commit 7d9d251

Please sign in to comment.