Moonlight piano roll: add #sparse #lush #wall anchor links
This commit is contained in:
parent
2bb4b9b69a
commit
fee50e5005
1 changed files with 12 additions and 8 deletions
|
|
@ -446,19 +446,16 @@ function tick(now) {
|
||||||
// ── Version switching ─────────────────────────────────────────────────────────
|
// ── Version switching ─────────────────────────────────────────────────────────
|
||||||
let currentVersion = 'sparse';
|
let currentVersion = 'sparse';
|
||||||
|
|
||||||
function setVersion(v) {
|
function setVersion(v, pushHash) {
|
||||||
|
if (!['sparse','lush','wall'].includes(v)) v = 'sparse';
|
||||||
if (v === currentVersion) return;
|
if (v === currentVersion) return;
|
||||||
stop();
|
stop();
|
||||||
currentVersion = v;
|
currentVersion = v;
|
||||||
['sparse','lush','wall'].forEach(x => {
|
['sparse','lush','wall'].forEach(x => {
|
||||||
document.getElementById('v-'+x).classList.toggle('active', x === v);
|
document.getElementById('v-'+x).classList.toggle('active', x === v);
|
||||||
});
|
});
|
||||||
|
if (pushHash !== false) history.replaceState(null, '', '#' + v);
|
||||||
if (v === 'wall') {
|
loadVersion(v === 'wall' ? WALL_NOTES : v === 'lush' ? LUSH_NOTES : SPARSE_NOTES);
|
||||||
loadVersion(WALL_NOTES);
|
|
||||||
} else {
|
|
||||||
loadVersion(v === 'sparse' ? SPARSE_NOTES : LUSH_NOTES);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadVersion(notes) {
|
function loadVersion(notes) {
|
||||||
|
|
@ -467,11 +464,18 @@ function loadVersion(notes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Init ──────────────────────────────────────────────────────────────────────
|
// ── Init ──────────────────────────────────────────────────────────────────────
|
||||||
|
window.addEventListener('hashchange', () => {
|
||||||
|
setVersion(window.location.hash.slice(1), false);
|
||||||
|
});
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
initSizes();
|
initSizes();
|
||||||
drawRuler();
|
drawRuler();
|
||||||
drawKeys(new Set());
|
drawKeys(new Set());
|
||||||
loadVersion(SPARSE_NOTES);
|
const initV = ['sparse','lush','wall'].includes(window.location.hash.slice(1))
|
||||||
|
? window.location.hash.slice(1) : 'sparse';
|
||||||
|
currentVersion = ''; // force setVersion to run
|
||||||
|
setVersion(initV, false);
|
||||||
|
|
||||||
// sync ruler scroll with roll scroll
|
// sync ruler scroll with roll scroll
|
||||||
rollOuter.addEventListener('scroll', () => {
|
rollOuter.addEventListener('scroll', () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue