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