Fixing mouse detection
This commit is contained in:
@ -127,6 +127,11 @@ export class UserAPI {
|
||||
// Mouse functions
|
||||
// =============================================================
|
||||
|
||||
onmousemove = (e: MouseEvent) => {
|
||||
this.app._mouseX = e.clientX;
|
||||
this.app._mouseY = e.clientY;
|
||||
}
|
||||
|
||||
public mouseX = (): number => {
|
||||
/**
|
||||
* @returns The current x position of the mouse
|
||||
|
||||
@ -6,7 +6,6 @@ const key_shortcut = (shortcut: string): string => {
|
||||
|
||||
const samples_to_markdown = (application: Editor) => {
|
||||
let samples = application.api._all_samples();
|
||||
console.log(samples)
|
||||
let markdownList = "";
|
||||
let keys = Object.keys(samples);
|
||||
let i = -1;
|
||||
|
||||
18
src/main.ts
18
src/main.ts
@ -628,7 +628,7 @@ export class Editor {
|
||||
if (universeParam !== null) {
|
||||
new_universe = JSON.parse(atob(universeParam));
|
||||
const randomName: string = uniqueNamesGenerator({
|
||||
length: 2, separator: '',
|
||||
length: 2, separator: '_',
|
||||
dictionaries: [colors, animals],
|
||||
});
|
||||
this.loadUniverse(randomName, new_universe["universe"]);
|
||||
@ -970,15 +970,7 @@ export class Editor {
|
||||
// Creating the application
|
||||
const app = new Editor();
|
||||
|
||||
/**
|
||||
* @param event The mouse event
|
||||
*/
|
||||
function reportMouseCoordinates(event: MouseEvent) {
|
||||
app._mouseX = event.clientX;
|
||||
app._mouseY = event.clientY;
|
||||
}
|
||||
|
||||
window.addEventListener("mousemove", reportMouseCoordinates);
|
||||
|
||||
// When the user leaves the page, all the universes should be saved in the localStorage
|
||||
window.addEventListener("beforeunload", () => {
|
||||
@ -991,3 +983,11 @@ window.addEventListener("beforeunload", () => {
|
||||
app.clock.stop();
|
||||
return null;
|
||||
});
|
||||
|
||||
// function reportMouseCoordinates(event: MouseEvent) {
|
||||
// app._mouseX = event.clientX;
|
||||
// app._mouseY = event.clientY;
|
||||
// }
|
||||
|
||||
onmousemove = function(e){console.log("mouse location:", e.clientX, e.clientY)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user