bitview: small fixes

This commit is contained in:
nym21
2025-08-30 12:11:15 +02:00
parent e106d30852
commit 5ba7ce5b7c
4 changed files with 19 additions and 17 deletions
@@ -208,7 +208,7 @@ function createChartElement({
const activeResources = /** @type {Set<VecResource>} */ (new Set());
ichart.subscribeCrosshairMove(
utils.debounce(() => {
utils.throttle(() => {
activeResources.forEach((v) => {
v.fetch();
});
+4 -5
View File
@@ -127,11 +127,10 @@ export function init({
}
chart.inner.timeScale().subscribeVisibleLogicalRangeChange(
utils.debounce((t) => {
if (t) {
from.set(t.from);
to.set(t.to);
}
utils.throttle((t) => {
if (!t) return;
from.set(t.from);
to.set(t.to);
}),
);
+10 -10
View File
@@ -1351,20 +1351,20 @@ function createUtils() {
* @param {F} callback
* @param {number} [wait=250]
*/
function debounce(callback, wait = 250) {
/** @type {number | undefined} */
let timeoutId;
function throttle(callback, wait = 250) {
/** @type {number | null} */
let timeoutId = null;
/** @type {Parameters<F>} */
let latestArgs;
return (/** @type {Parameters<F>} */ ...args) => {
return async (/** @type {Parameters<F>} */ ...args) => {
latestArgs = args;
if (!timeoutId) {
timeoutId = window.setTimeout(async () => {
await callback(...latestArgs);
timeoutId = undefined;
await callback(...latestArgs); // Execute immediately
timeoutId = setTimeout(async () => {
await callback(...latestArgs); // Execute with latest args
timeoutId = null;
}, wait);
}
};
@@ -1569,7 +1569,7 @@ function createUtils() {
serde,
formatters,
date,
debounce,
throttle,
runWhenIdle,
getNumberOfDaysBetweenTwoDates,
stringToId,
@@ -2246,7 +2246,7 @@ function main() {
let firstTimeLoadingExplorer = true;
signals.createEffect(options.selected, (option) => {
console.log(utils.url.pathnameToSelectedId(), option.id);
// console.log(utils.url.pathnameToSelectedId(), option);
if (previousElement) {
previousElement.hidden = true;
utils.url.resetParams(option);
+4 -1
View File
@@ -3016,7 +3016,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
}),
createBaseSeries({
key: "days_since_ath",
name: "Days since",
name: "since",
}),
createBaseSeries({
key: "max_days_between_aths",
@@ -3459,6 +3459,9 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
key: "difficulty_as_hash",
name: "difficulty",
color: colors.default,
options: {
lineStyle: 1,
},
}),
],
},