I am wondering if I could get this button to auto hide after scrolling 30%
Hi there, @Rev_Devan ![]()
Please let me discuss it with the dev team. I’ll get back to you once I have any news ![]()
Yep, it’s possible to implement this customization. One question: would you like the widget to appear again if the scroll is back to 30% position?
Yes that would be great, and if flexible with the percentage so I can play with what’s best.
Got you!
Your request is with our devs now. I’ll update you once the solution is ready ![]()
I see it working but I guess I was hoping it would fade out slowly as the scroll continue to be completely gone by 50% and start fading at 30%.
Okay! I’ll ask the devs if it’s feasible and will get back to you later ![]()
Hi there, @Rev_Devan ![]()
We’ve adjusted the script in the Custom JS field on the Settings tab and now the widget gradually fades out when scrolling:
const MIN_THRESHOLD = 0.3;
const MAX_THRESHOLD = 0.5;
const WIDGET_SELECTOR = ".eapps-accessibility-05a2ed38-2a13-452f-bcc8-b1db9113f17e-custom-css-root";
const widgetСontainer = document.querySelector(WIDGET_SELECTOR);
const getScrollPosition = () => {
const scrollTop = window.scrollY || document.documentElement.scrollTop;
const docHeight = document.documentElement.scrollHeight;
const winHeight = window.innerHeight;
const trackLength = docHeight - winHeight;
return Math.floor((scrollTop / trackLength) * 100);
};
const changeWidgetVisibility = () => {
const scrollPercentage = getScrollPosition() / 100;
const isPastMaxThreshold = scrollPercentage >= MAX_THRESHOLD;
const isInMinThreshold = scrollPercentage <= MIN_THRESHOLD;
if (isPastMaxThreshold || isInMinThreshold) {
Object.assign(widgetСontainer.style, {
opacity: isPastMaxThreshold ? 0 : 1,
display: isPastMaxThreshold ? "none" : "block"
});
return;
}
const fadeRange = MAX_THRESHOLD - MIN_THRESHOLD;
const currentFade = scrollPercentage - MIN_THRESHOLD;
const opacity = 1 - (currentFade / fadeRange);
Object.assign(widgetСontainer.style, {
opacity,
display: "block"
});
};
changeWidgetVisibility();
document.addEventListener("scroll", changeWidgetVisibility);
Please check your website and let me know if you like how the script works ![]()