Hi,
I have recently integrated anchors into my site for quality of life purposes, namely with folding elements.
Unfortunately, I am having some issues when my anchor that I am travelling to is far down the page.
The intended result is a smooth transition to the anchor, but the actual result is a jerky snap to the bottom of the page.
This is illustrated in the clip shown, where I first show it working as it should, then what happens when clicking on a fold that is further down the page:
Here is my relevant current code, using the functionality found in a Wix-Code tutorial on folds .
function toggleFold(index) {
let $fold = $w('#fold' + index);
// Store the anchor required
let $anchor = $w('#ncr' + index);
let $arrowDown = $w('#arrowDown' + index);
let $arrowRight = $w('#arrowRight' + index);
// toggle the fold at the index
if ($fold.collapsed) {
$fold.expand();
// Scroll to the anchor
$anchor.scrollTo();
$arrowDown.show();
$arrowRight.hide();
} else {
$fold.collapse();
$arrowDown.hide();
$arrowRight.show();
}
// collapse the other folds
[1, 2, 3, 4]
.filter(idx => idx !== index)
.forEach(idx => {
$w('#fold' + idx).collapse();
$w('#arrowDown' + idx).hide();
$w('#arrowRight' + idx).show();
});
}
The anchor names and numbers match up with the fold numbers, so the index cannot be the issue.
Any ideas?