Moved "Clear Traces" tool to Utilities
This commit is contained in:
parent
ef51f436c3
commit
e50be0b874
@ -49,7 +49,7 @@ export class Sim {
|
||||
this.toolbars = {
|
||||
tools: new Toolbar(this, 'Tools'),
|
||||
modes: new Toolbar(this, 'Modes'),
|
||||
utils: new Toolbar(this, 'Utility'),
|
||||
utils: new Toolbar(this, 'Utility', { expanded: false }),
|
||||
options: new Toolbar(this, 'Options'),
|
||||
params: new Toolbar(this, 'Parameters'),
|
||||
debug: new Toolbar(this, 'Debug', { expanded: false }),
|
||||
|
||||
@ -4,11 +4,9 @@ import {Tool} from '../tool.js';
|
||||
export class PlayPause extends Tool {
|
||||
playHTML = 'Play';
|
||||
pauseHTML = 'Pause';
|
||||
clearTracesText = 'Clear Traces';
|
||||
currentTimeEl = undefined;
|
||||
pauseButton = undefined;
|
||||
playButton = undefined;
|
||||
clearTracesEl = undefined;
|
||||
|
||||
get timeText() {
|
||||
let time = this.sim.time;
|
||||
@ -51,25 +49,20 @@ export class PlayPause extends Tool {
|
||||
const currentTime = document.createElement('button');
|
||||
const pauseButton = document.createElement('button');
|
||||
const playButton = document.createElement('button');
|
||||
const clearTraces = document.createElement('button');
|
||||
this.pauseButton = pauseButton;
|
||||
this.playButton = playButton;
|
||||
this.clearTracesEl = clearTraces;
|
||||
this.currentTimeEl = currentTime;
|
||||
|
||||
this.div.appendChild(currentTime);
|
||||
this.div.appendChild(pauseButton);
|
||||
this.div.appendChild(playButton);
|
||||
this.div.appendChild(clearTraces);
|
||||
|
||||
currentTime.classList.add(TOOL_INFO_CLASSNAME);
|
||||
currentTime.classList.add(WIDE_CLASSNAME);
|
||||
clearTraces.classList.add(WIDE_CLASSNAME);
|
||||
|
||||
pauseButton.innerHTML = this.pauseHTML;
|
||||
playButton.innerHTML = this.playHTML;
|
||||
currentTime.innerHTML = this.timeText;
|
||||
clearTraces.innerHTML = this.clearTracesText;
|
||||
|
||||
this.updateButtons();
|
||||
|
||||
@ -87,12 +80,5 @@ export class PlayPause extends Tool {
|
||||
this.updateButtons();
|
||||
}
|
||||
});
|
||||
|
||||
clearTraces.addEventListener('click', () => {
|
||||
// Obliterate object histories
|
||||
this.sim.objects.forEachObject(obj => {
|
||||
obj.history = [];
|
||||
}, {alive: null});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,14 +4,20 @@ import {
|
||||
} from '../config.js';
|
||||
|
||||
export class UtilityTool extends Tool {
|
||||
|
||||
constructor(toolbar) {
|
||||
super(toolbar);
|
||||
|
||||
const zeroVelocity = document.createElement('button');
|
||||
const clearTraces = document.createElement('button');
|
||||
|
||||
this.div.appendChild(clearTraces);
|
||||
this.div.appendChild(zeroVelocity);
|
||||
|
||||
zeroVelocity.classList.add(WIDE_CLASSNAME);
|
||||
clearTraces.classList.add(WIDE_CLASSNAME);
|
||||
|
||||
zeroVelocity.innerHTML = 'Zero Momentum';
|
||||
clearTraces.innerHTML = 'Clear Traces';
|
||||
|
||||
zeroVelocity.addEventListener('click', () => {
|
||||
// Determine center of mass and average momentum
|
||||
@ -30,5 +36,12 @@ export class UtilityTool extends Tool {
|
||||
// Cancel panning
|
||||
this.sim.panning = undefined;
|
||||
});
|
||||
|
||||
clearTraces.addEventListener('click', () => {
|
||||
// Obliterate object histories
|
||||
this.sim.objects.forEachObject(obj => {
|
||||
obj.history = [];
|
||||
}, {alive: null});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user