forked from MichiSpebach/mammutmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorialRenderManager.ts
More file actions
50 lines (45 loc) · 1.62 KB
/
tutorialRenderManager.ts
File metadata and controls
50 lines (45 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { MenuItemFile, applicationMenu, renderManager, coreUtil, RenderPriority, RenderElement } from '../dist/pluginFacade'
applicationMenu.addMenuItemTo('tutorialRenderManager.js', new MenuItemFile({label: 'add element', click: () => addElement()}))
async function addElement(): Promise<void> {
const id: string = coreUtil.generateId()
const removeButton: RenderElement = {
type: 'button',
style: {
display: 'block',
margin: 'auto',
marginTop: '10px',
cursor: 'pointer'
},
onclick: () => renderManager.remove(id),
children: 'Remove Element'
}
await renderManager.addElementTo('body', {
type: 'div',
id,
style: {
position: 'fixed',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
transition: 'all 0.5s',
backgroundColor: '#1248',
padding: '10px',
border: 'solid 1px',
borderRadius: '4px'
},
onmouseenter: () => highlightElement(id),
onmouseleave: () => resetElement(id),
children: [
{type: 'div', children: 'Use RenderPriority.RESPONSIVE to prioritize render operations over other render operations'},
{type: 'div', children: 'to achieve responsiveness for them when other render operations are queued up.'},
{type: 'div', children: 'But save RenderPriority.RESPONSIVE for the things that really need to be responsive.'},
removeButton
]
})
}
async function highlightElement(elementId: string): Promise<void> {
await renderManager.addStyleTo(elementId, {color: 'skyblue'}, RenderPriority.RESPONSIVE)
}
async function resetElement(elementId: string): Promise<void> {
await renderManager.addStyleTo(elementId, {color: null}, RenderPriority.RESPONSIVE)
}