@proca/widget
Version:
Proca is an open-source campaign toolkit designed to empower activists and organisations in their digital advocacy efforts. It provides a flexible and customisable platform for creating and managing online petitions, email campaigns, and other forms of di
24 lines (22 loc) • 553 B
JavaScript
const scrollTo = params => {
const {
delay = 100,
block = "center",
selector = ".proca-widget",
focus = undefined,
} = params || {};
setTimeout(() => {
const widget = document.querySelector(selector);
if (!widget) return;
widget.scrollIntoView({ block: block, behavior: "smooth" });
if (focus) {
const field = document.getElementsByName(params.focus);
if (field.length === 1) {
setTimeout(() => {
field[0].focus();
}, 1000);
}
}
}, delay);
};
export { scrollTo };