scrollToSmooth
scrollToSmooth copied to clipboard
Bug: Offset by number ignored
Code gets to this point:
if (this.settings.offset !== null) {
var offset = 0;
if (validateSelector(this.settings.offset, this.container)) {
var offsetElement = this.settings.offset;
if (typeof offsetElement == 'string') {
offsetElement = _$(this.settings.offset);
}
if (isNodeOrElement(offsetElement)) {
offset = offsetElement.getBoundingClientRect().height;
}
} else if (!isNaN(this.settings.offset)) {
offset = this.settings.offset;
if (typeof offset === 'string') {
offset = parseFloat(offset);
}
}
distFromTop -= offset;
Hits this line if (validateSelector(this.settings.offset, this.container)) {
Which calls validateSelector(500, undefined).
var validateSelector = function validateSelector(selector) {
var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : d;
var valid = true; // Check if the target is a valid selector inside the scrollToSmooth container
try {
if (typeof selector === 'string') {
_$(selector, container);
} else if (isNodeOrElement(selector) && container.contains(selector)) {
selector;
}
} catch (e) {
valid = false;
}
return valid;
};
which results in nothing being thrown, so 500 is considered a "valid selector", which means offset gets changed to 0.
Hi @TheJaredWilcurt I couldn't reproduce your issue yet. Can you post your configuration file here so I can have a look at it.
I will close this issue for now as there was no response.