Improvement suggestion: allow more control over speed Auto (option) formula
diegocanal opened this issue · 2 comments
Hi Karl,
When having very long pages the (current scroll position - target scroll position) / autoCoefficient
formula does not provide us with enough control to get a reasonable balance between anchor links that have their targets very close to them and the ones that have their targets far away from them, i.e., If:
autoCoefficient
is set to a low value, when anchor links with distant targets are clicked, the resulting smooth scrolling is painfully slow.autoCoefficient
is set to a value high enough to fix the aforementioned slowness, when anchor links with closer targets are clicked, the resulting smooth scrolling is too fast –almost seems instantaneous (as if it wasn't smooth)–.
I suggest to create an extra option, apart from autoCoefficient
so we'd end up with the formula:
(current scroll position - target scroll position + NewOption) / autoCoefficient
I've tried it and it works much better, for example, for autoCoefficient: 9
I have modified the code into:
speed = (delta + 20000) / opts.autoCoefficient;
}
You can see it in action here: 28 ejemplos de modificación de medidas por un abogado en Madrid. Please, try the anchor links:
- Cambios que te afectan a ti o a tu ex (sección 2)
- Cambios que afectan a tus hijos (sección 3)
- Cambios legales o jurisprudenciales (sección 4)
Thanks!
Hi Diego!
This seems fine to me. 2 questions:
- any idea on what to name the option?
- Does it need to be so precise? For example, maybe it would be nicer for user to enter a value like
20
, so the code would read:
speed = (delta + (1000 * opts.newOption) / opts.autoCoefficient;
thoughts?
Hi Karl!
I appreciate you have taken the suggestion into consideration.
Answering your questions:
- Some ideas: maxSpeedLimiter, maxSpeedOffset, maxSpeedBalancer, maxSpeedAdjustment, speedLimiter, speedOffset, speedBalancer, speedAdjustment…or simply maxSpeed.
- You are absolutely correct, it doesn't need to be so precise. What you propose is perfect, a 2 digit number to be entered by the user –multiplied by 1000 in the formula– will provide plenty enough room to make the right adjustments.
Thanks!