eslint
This commit is contained in:
parent
a1af83b392
commit
e3fe7bd4e4
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
*.sw[po]
|
||||
node_modules/
|
||||
|
||||
25
UNLICENSE
Normal file
25
UNLICENSE
Normal file
@ -0,0 +1,25 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <https://unlicense.org/>
|
||||
|
||||
7
eslint.config.mjs
Normal file
7
eslint.config.mjs
Normal file
@ -0,0 +1,7 @@
|
||||
import js from "@eslint/js";
|
||||
import globals from "globals";
|
||||
import { defineConfig } from "eslint/config";
|
||||
|
||||
export default defineConfig([
|
||||
{ files: ["**/*.{js,mjs,cjs}"], plugins: { js }, extends: ["js/recommended"], languageOptions: { globals: globals.browser } },
|
||||
]);
|
||||
@ -2,7 +2,6 @@ import { MassObject } from './object.js';
|
||||
import {
|
||||
MASS_CREATION_RATE,
|
||||
DISPLAY_OBJECTS_INFO,
|
||||
MOTION_TIME_SCALE,
|
||||
GRAVITATIONAL_CONSTANT,
|
||||
ZOOM_TO_FIT_PADDING,
|
||||
} from './config.js';
|
||||
@ -57,7 +56,6 @@ export class Objects {
|
||||
|
||||
doneCreatingObject() {
|
||||
if (this.creatingObject !== undefined) {
|
||||
const obj = this.objects[this.creatingObject];
|
||||
this.creatingObject = undefined;
|
||||
this.resume();
|
||||
}
|
||||
@ -138,7 +136,7 @@ export class Objects {
|
||||
}
|
||||
}
|
||||
|
||||
handlePointerUp({x, y}) {
|
||||
handlePointerUp() {
|
||||
this.doneCreatingObject();
|
||||
this.deselect();
|
||||
}
|
||||
|
||||
1090
package-lock.json
generated
Normal file
1090
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
21
package.json
Normal file
21
package.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "gravity",
|
||||
"version": "0.2.0",
|
||||
"description": "Gravity Simulator",
|
||||
"main": "simulator.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"lint": "npx eslint"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@git.laddhoffman.com:lentil/gravity.git"
|
||||
},
|
||||
"author": "Ladd Hoffman <lentil@laddhoffman.com>",
|
||||
"license": "Unlicense",
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.2",
|
||||
"eslint": "^9.39.2",
|
||||
"globals": "^16.5.0"
|
||||
}
|
||||
}
|
||||
11
pointer.js
11
pointer.js
@ -1,18 +1,13 @@
|
||||
import {
|
||||
POINTER_HISTORY_SIZE,
|
||||
ZOOM_IN_FACTOR,
|
||||
ZOOM_OUT_FACTOR,
|
||||
DISPLAY_CURSOR_INFO,
|
||||
DRAGGABLE_ELEMENT_CLASSNAME,
|
||||
MODE_MASS_GENERATION,
|
||||
MODE_PAN_VIEW,
|
||||
POINTER_HISTORY_SIZE,
|
||||
ZOOM_IN_FACTOR,
|
||||
ZOOM_OUT_FACTOR,
|
||||
} from './config.js';
|
||||
|
||||
function dispatchEvent(target, eventType, data) {
|
||||
const ev = new CustomEvent(eventType, {detail: data});
|
||||
target.dispatchEvent(ev);
|
||||
}
|
||||
|
||||
export class Pointer {
|
||||
sim = undefined;
|
||||
|
||||
|
||||
@ -40,11 +40,11 @@ export class ModeSwitch extends Tool {
|
||||
button.innerHTML = `<h3>${modeTitle}</h3>`;
|
||||
button.classList.add('wide');
|
||||
|
||||
button.addEventListener('click', (e) => this.setCurrentMode(modeID));
|
||||
button.addEventListener('click', () => this.setCurrentMode(modeID));
|
||||
}
|
||||
|
||||
// First listed mode is the default
|
||||
const [[currentModeID, _]] = this.modes;
|
||||
const [[currentModeID, ]] = this.modes;
|
||||
this.setCurrentMode(currentModeID);
|
||||
|
||||
// Add global method to set/get current mode
|
||||
|
||||
@ -29,7 +29,7 @@ export class PlayPause extends Tool {
|
||||
}
|
||||
});
|
||||
|
||||
playButton.addEventListener('click', (e) => {
|
||||
playButton.addEventListener('click', () => {
|
||||
if (!this.playing) {
|
||||
this.playing = true;
|
||||
pauseButton.style.opacity = '100%';
|
||||
@ -43,6 +43,6 @@ export class PlayPause extends Tool {
|
||||
}
|
||||
|
||||
set playing(playing) {
|
||||
return this.sim.playing = playing;
|
||||
this.sim.playing = playing;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ export class Toolbar {
|
||||
frame() {
|
||||
for (let tool in this.tools) {
|
||||
// TODO: tool.frame()
|
||||
tool.frame();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user