build
Browse files- dist/main.bundle.js +86 -0
- dist/main.bundle.js.map +0 -0
dist/main.bundle.js
CHANGED
|
@@ -5544,14 +5544,100 @@ function _loadFragments() {
|
|
| 5544 |
return _loadFragments.apply(this, arguments);
|
| 5545 |
}
|
| 5546 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5547 |
;// ./src/index.js
|
| 5548 |
// import { plotClusters } from './clusters'
|
| 5549 |
|
| 5550 |
|
|
|
|
| 5551 |
document.addEventListener("DOMContentLoaded", function () {
|
| 5552 |
console.log("DOMContentLoaded");
|
| 5553 |
loadFragments();
|
| 5554 |
init_memory_plot();
|
|
|
|
| 5555 |
}, {
|
| 5556 |
once: true
|
| 5557 |
});
|
|
|
|
| 5544 |
return _loadFragments.apply(this, arguments);
|
| 5545 |
}
|
| 5546 |
|
| 5547 |
+
;// ./src/syncHFSpacesURLHash.js
|
| 5548 |
+
var queryArg = "section";
|
| 5549 |
+
function syncHFSpacesURLHash() {
|
| 5550 |
+
// Check for section parameter in URL
|
| 5551 |
+
var urlParams = new URLSearchParams(window.location.search);
|
| 5552 |
+
var sectionId = urlParams.get(queryArg);
|
| 5553 |
+
if (sectionId) {
|
| 5554 |
+
// Find the element with the specified ID
|
| 5555 |
+
var targetElement = document.getElementById(sectionId);
|
| 5556 |
+
|
| 5557 |
+
// scroll if the element exists
|
| 5558 |
+
if (targetElement) {
|
| 5559 |
+
targetElement.scrollIntoView();
|
| 5560 |
+
history.replaceState(null, null, "#".concat(sectionId));
|
| 5561 |
+
}
|
| 5562 |
+
}
|
| 5563 |
+
updateHashBasedOnHashChange();
|
| 5564 |
+
|
| 5565 |
+
// Variables to manage throttling
|
| 5566 |
+
var isScrolling = false;
|
| 5567 |
+
var lastKnownScrollPosition = 0;
|
| 5568 |
+
|
| 5569 |
+
// Add the scroll event listener here
|
| 5570 |
+
window.addEventListener('scroll', function () {
|
| 5571 |
+
lastKnownScrollPosition = window.scrollY;
|
| 5572 |
+
if (!isScrolling) {
|
| 5573 |
+
window.requestAnimationFrame(function () {
|
| 5574 |
+
updateHashBasedOnScroll(lastKnownScrollPosition);
|
| 5575 |
+
isScrolling = false;
|
| 5576 |
+
});
|
| 5577 |
+
}
|
| 5578 |
+
isScrolling = true;
|
| 5579 |
+
});
|
| 5580 |
+
|
| 5581 |
+
// Initial hash update on page load
|
| 5582 |
+
updateHashBasedOnScroll(window.scrollY);
|
| 5583 |
+
}
|
| 5584 |
+
|
| 5585 |
+
// Function to update the URL hash based on scroll position
|
| 5586 |
+
function updateHashBasedOnScroll(scrollPosition) {
|
| 5587 |
+
// Get only heading elements with IDs that we want to track
|
| 5588 |
+
var elementsWithIds = Array.from(document.querySelectorAll('h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]'));
|
| 5589 |
+
|
| 5590 |
+
// Skip updating if there are no elements with IDs
|
| 5591 |
+
if (elementsWithIds.length === 0) return;
|
| 5592 |
+
|
| 5593 |
+
// Find the element closest to the top of the viewport
|
| 5594 |
+
var closestElement = null;
|
| 5595 |
+
var closestDistance = Infinity;
|
| 5596 |
+
var viewportMiddle = scrollPosition + window.innerHeight / 2;
|
| 5597 |
+
|
| 5598 |
+
// Iterate through all elements with IDs to find the closest one
|
| 5599 |
+
elementsWithIds.forEach(function (element) {
|
| 5600 |
+
var elementTop = element.getBoundingClientRect().top + scrollPosition;
|
| 5601 |
+
var distance = Math.abs(elementTop - viewportMiddle);
|
| 5602 |
+
if (distance < closestDistance) {
|
| 5603 |
+
closestDistance = distance;
|
| 5604 |
+
closestElement = element;
|
| 5605 |
+
}
|
| 5606 |
+
});
|
| 5607 |
+
|
| 5608 |
+
// Update the URL hash if we found a closest element
|
| 5609 |
+
if (closestElement && closestElement.id) {
|
| 5610 |
+
// Only update if the hash is different to avoid unnecessary history entries
|
| 5611 |
+
if (window.location.hash !== "#".concat(closestElement.id)) {
|
| 5612 |
+
// Update the URL without adding a new history entry
|
| 5613 |
+
history.replaceState(null, null, "#".concat(closestElement.id));
|
| 5614 |
+
postMessageToHFSpaces(closestElement.id);
|
| 5615 |
+
}
|
| 5616 |
+
}
|
| 5617 |
+
}
|
| 5618 |
+
function updateHashBasedOnHashChange() {
|
| 5619 |
+
window.addEventListener('hashchange', function () {
|
| 5620 |
+
var elementId = window.location.hash.slice(1);
|
| 5621 |
+
postMessageToHFSpaces(elementId);
|
| 5622 |
+
});
|
| 5623 |
+
}
|
| 5624 |
+
function postMessageToHFSpaces(elementId) {
|
| 5625 |
+
var parentOrigin = "https://huggingface.co";
|
| 5626 |
+
window.parent.postMessage({
|
| 5627 |
+
queryString: "".concat(queryArg, "=").concat(elementId)
|
| 5628 |
+
}, parentOrigin);
|
| 5629 |
+
}
|
| 5630 |
+
|
| 5631 |
;// ./src/index.js
|
| 5632 |
// import { plotClusters } from './clusters'
|
| 5633 |
|
| 5634 |
|
| 5635 |
+
|
| 5636 |
document.addEventListener("DOMContentLoaded", function () {
|
| 5637 |
console.log("DOMContentLoaded");
|
| 5638 |
loadFragments();
|
| 5639 |
init_memory_plot();
|
| 5640 |
+
syncHFSpacesURLHash();
|
| 5641 |
}, {
|
| 5642 |
once: true
|
| 5643 |
});
|
dist/main.bundle.js.map
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|