nullify contextmenu
This commit is contained in:
parent
b6b069450d
commit
0e4ae45d01
2 changed files with 12 additions and 9 deletions
|
@ -83,6 +83,10 @@ export class Agent {
|
||||||
{ once: true }
|
{ once: true }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
this.cnv.addEventListener('contextmenu', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
// TODO: Custom context menu support
|
||||||
|
});
|
||||||
document.addEventListener('mousemove', (e) => {
|
document.addEventListener('mousemove', (e) => {
|
||||||
if (!this.dragging) return;
|
if (!this.dragging) return;
|
||||||
this.x += e.movementX;
|
this.x += e.movementX;
|
||||||
|
@ -180,9 +184,11 @@ export class Agent {
|
||||||
}
|
}
|
||||||
|
|
||||||
hide(remove: boolean = false) {
|
hide(remove: boolean = false) {
|
||||||
this.playAnimationByName('Hide', () => {
|
this.playAnimationByName("Hide", () => {
|
||||||
if (remove) this.remove();
|
if(remove)
|
||||||
else this.cnv.style.display = 'none';
|
this.remove();
|
||||||
|
else
|
||||||
|
this.cnv.style.display = 'none';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
import * as msagent from "@msagent-chat/msagent.js";
|
import * as msagent from "@msagent-chat/msagent.js";
|
||||||
let w = window as any;
|
let w = window as any;
|
||||||
|
w.agents = [];
|
||||||
let input = document.getElementById("testbed-input") as HTMLInputElement;
|
let input = document.getElementById("testbed-input") as HTMLInputElement;
|
||||||
|
|
||||||
input.addEventListener("change", async () => {
|
input.addEventListener("change", async () => {
|
||||||
|
@ -11,12 +12,8 @@ input.addEventListener("change", async () => {
|
||||||
console.log("Creating agent");
|
console.log("Creating agent");
|
||||||
let agent = msagent.agentCreateCharacter(new Uint8Array(buffer));
|
let agent = msagent.agentCreateCharacter(new Uint8Array(buffer));
|
||||||
|
|
||||||
// destroy the previous agent
|
w.agents.push(agent);
|
||||||
if(w.agent != null) {
|
|
||||||
w.agent.hide(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
w.agent = agent;
|
|
||||||
agent.addToDom(document.body);
|
agent.addToDom(document.body);
|
||||||
|
|
||||||
agent.show();
|
agent.show();
|
||||||
|
|
Loading…
Reference in a new issue