logAxisSplits doesn't terminate with scale agnostic `wheelZoomPlugin` plugin
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.5k
- Forks
- 463
- PR merge metrics
- No merged PRs in 30d
Description
I wrote a scale agnostic wheelZoomPlugin plugin, that doesn't seem like it would cause a browser freeze.
But after on average one minute of zooming in and out with it, the browser always freezes in the loop in logAxisSplits. I assume that this isn't a problem only I will run into, hence I'm writing this issue.
I was able solve it by adding the following code:
do {
splits.push(split);
split = split + foundIncr;
+ let dec = fixedDec.get(foundIncr);
+ if (dec == undefined)
+ break;
if (logBase == 10)
- split = roundDec(split, fixedDec.get(foundIncr));
+ split = roundDec(split, dec);
if (split >= foundIncr * logBase)
foundIncr = split;
} while (split <= scaleMax);
This isn't a pr, because I'm not sure what the underlying cause is, and it may be better to address that.
Here is the wheelZoomPlugin plugin I used:
function wheelZoomPlugin(opts)
{
let xfactor = opts.xfactor || 0.75;
let yfactor = opts.yfactor || 0.75;
return {
hooks: {
ready: u => {
let over = u.over;
let rect = over.getBoundingClientRect();
// wheel scroll zoom
over.addEventListener("wheel", e => {
e.preventDefault();
let {left, top} = u.cursor;
let xs = e.deltaY < 0 ? xfactor : 2-xfactor;
let x1 = rect.width - left;
let x2 = left;
let nxMax = u.posToVal(left + x1*xs, "x");
let nxMin = u.posToVal(left - x2*xs, "x");
let ys = e.deltaY < 0 ? yfactor : 2-yfactor;
let y1 = rect.height - top;
let y2 = top;
let nyMax = u.posToVal(top + y1*ys, "y");
let nyMin = u.posToVal(top - y2*ys, "y");
u.batch(() => {
u.setScale("x", {
min: nxMin,
max: nxMax,
});
u.setScale("y", {
min: nyMin,
max: nyMax,
});
});
});
}
}
};
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the loop in logAxisSplits, especially the fixedDec.get(foundIncr) lookup, and reproduce the problem with the supplied scale-agnostic wheelZoomPlugin. Determine why repeated zooming leaves the loop non-terminating; done means zooming in and out no longer freezes the browser.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100