web head node logic changed
This commit is contained in:
@@ -19,7 +19,7 @@ export class DoricContext {
|
||||
contextId = getContextId()
|
||||
pluginInstances: Map<string, DoricPlugin> = new Map
|
||||
rootNode: DoricStackNode
|
||||
headNodes: Map<string, DoricViewNode> = new Map
|
||||
headNodes: Map<string, Map<string, DoricViewNode>> = new Map
|
||||
|
||||
constructor(content: string) {
|
||||
createContext(this.contextId, content)
|
||||
|
@@ -3,6 +3,8 @@ import { DVModel, DoricViewNode } from '../shader/DoricViewNode';
|
||||
import { DoricContext } from '../DoricContext';
|
||||
|
||||
export class PopoverPlugin extends DoricPlugin {
|
||||
static TYPE = "popover"
|
||||
|
||||
fullScreen = document.createElement('div')
|
||||
constructor(context: DoricContext) {
|
||||
super(context)
|
||||
@@ -22,7 +24,16 @@ export class PopoverPlugin extends DoricPlugin {
|
||||
viewNode.init()
|
||||
viewNode.blend(model.props)
|
||||
this.fullScreen.appendChild(viewNode.view)
|
||||
this.context.headNodes.set(model.id, viewNode)
|
||||
|
||||
let map = this.context.headNodes.get(PopoverPlugin.TYPE)
|
||||
if (map) {
|
||||
map.set(model.id, viewNode)
|
||||
} else {
|
||||
map = new Map
|
||||
map.set(model.id, viewNode)
|
||||
this.context.headNodes.set(PopoverPlugin.TYPE, map)
|
||||
}
|
||||
|
||||
if (!document.body.contains(this.fullScreen)) {
|
||||
document.body.appendChild(this.fullScreen)
|
||||
}
|
||||
@@ -31,12 +42,16 @@ export class PopoverPlugin extends DoricPlugin {
|
||||
|
||||
dismiss(args?: { id: string }) {
|
||||
if (args) {
|
||||
const viewNode = this.context.headNodes.get(args.id)
|
||||
if (viewNode) {
|
||||
this.fullScreen.removeChild(viewNode.view)
|
||||
}
|
||||
if (this.context.headNodes.size === 0) {
|
||||
document.body.removeChild(this.fullScreen)
|
||||
let map = this.context.headNodes.get(PopoverPlugin.TYPE)
|
||||
if (map) {
|
||||
const viewNode = map.get(args.id)
|
||||
if (viewNode) {
|
||||
this.fullScreen.removeChild(viewNode.view)
|
||||
}
|
||||
|
||||
if (map.size === 0) {
|
||||
document.body.removeChild(this.fullScreen)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.dismissAll()
|
||||
@@ -44,10 +59,14 @@ export class PopoverPlugin extends DoricPlugin {
|
||||
return Promise.resolve()
|
||||
}
|
||||
dismissAll() {
|
||||
for (let node of this.context.headNodes.values()) {
|
||||
this.context.headNodes.delete(node.viewId)
|
||||
this.fullScreen.removeChild(node.view)
|
||||
let map = this.context.headNodes.get(PopoverPlugin.TYPE)
|
||||
if (map) {
|
||||
for (let node of map.values()) {
|
||||
map.delete(node.viewId)
|
||||
this.fullScreen.removeChild(node.view)
|
||||
}
|
||||
}
|
||||
|
||||
if (document.body.contains(this.fullScreen)) {
|
||||
document.body.removeChild(this.fullScreen)
|
||||
}
|
||||
|
@@ -7,9 +7,11 @@ export class ShaderPlugin extends DoricPlugin {
|
||||
if (this.context.rootNode.viewId === ret.id) {
|
||||
this.context.rootNode.blend(ret.props)
|
||||
} else {
|
||||
const viewNode = this.context.headNodes.get(ret.id)
|
||||
if (viewNode) {
|
||||
viewNode.blend(ret.props)
|
||||
for (let map of this.context.headNodes.values()) {
|
||||
const viewNode = map.get(ret.id)
|
||||
if (viewNode) {
|
||||
viewNode.blend(ret.props)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user