Spaces:
Running
on
Zero
Running
on
Zero
File size: 1,856 Bytes
5499f4d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
/**
* Script to handle text scrolling in the RAG Summarizer Arena
* Uses a simplified approach relying primarily on Gradio's autoscroll parameter
*/
// Scroll to the query section when loading new content
function scrollToQuerySection() {
const querySection = document.getElementById('query-section');
if (querySection) {
setTimeout(() => {
querySection.scrollIntoView({ behavior: 'smooth', block: 'start' });
console.log('Scrolled to query section');
}, 300); // Small delay to ensure content is loaded
}
}
// Set up event listeners when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
console.log('Setting up basic scroll helpers...');
// Monitor button clicks for scrolling to the query section
function setupButtonListeners() {
const tryAnotherBtn = document.getElementById('try-another-btn');
if (tryAnotherBtn && !tryAnotherBtn.hasAttribute('data-scroll-handler')) {
tryAnotherBtn.addEventListener('click', scrollToQuerySection);
tryAnotherBtn.setAttribute('data-scroll-handler', 'true');
console.log('Added listener to try-another-btn');
}
const randomQuestionBtn = document.querySelector('.query-button');
if (randomQuestionBtn && !randomQuestionBtn.hasAttribute('data-scroll-handler')) {
randomQuestionBtn.addEventListener('click', scrollToQuerySection);
randomQuestionBtn.setAttribute('data-scroll-handler', 'true');
console.log('Added listener to query-button');
}
}
// Set up button listeners
setupButtonListeners();
// Watch for DOM changes to catch dynamically added elements
const bodyObserver = new MutationObserver(() => {
setupButtonListeners();
});
// Start observing the body for changes
bodyObserver.observe(document.body, {
childList: true,
subtree: true
});
}); |