Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
$categoryPageBlocklist = ['featured'];

$gitHubReleaseDownloadsCounter = new GitHubReleaseDownloadsCounter();

$wooCommerceConsumerKey = getenv('WC_CONSUMER_KEY') ?: null;
$wooCommerceConsumerSecret = getenv('WC_CONSUMER_SECRET') ?: null;

Expand Down
2 changes: 1 addition & 1 deletion source/_assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ AOS.init({
}

// Attach scroll handler with debounce
window.addEventListener("scroll", debounce(handleScrollElements, 10));
window.addEventListener("scroll", debounce(handleScrollElements, 10), { passive: true });

// ====== scroll top js
function scrollTo(element, to = 0, duration = 500) {
Expand Down
93 changes: 93 additions & 0 deletions source/_assets/js/pages/pricing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
(function () {
"use strict";

function setupPricingComparisonStickyHeader() {
const section = document.querySelector("#pricing-comparison");
const stickyHeader = section?.querySelector(".pricing-comparison-sticky-header");
const stickyViewport = stickyHeader?.querySelector(".pricing-comparison-sticky-header__viewport");
const shell = section?.querySelector(".pricing-comparison-shell");
const tableWrapper = shell?.querySelector(".table-responsive");
const table = tableWrapper?.querySelector(".pricing-comparison-table");
const tableHead = table?.querySelector("thead");

if (!section || !stickyHeader || !stickyViewport || !shell || !tableWrapper || !table || !tableHead) {
return;
}

const stickyTable = document.createElement("table");
stickyTable.className = `${table.className} pricing-comparison-sticky-header-table`;
stickyTable.setAttribute("role", "presentation");
stickyTable.innerHTML = tableHead.outerHTML;
stickyViewport.replaceChildren(stickyTable);

const syncStickyColumnWidths = () => {
const originalCells = [...tableHead.querySelectorAll("th")];
const stickyCells = [...stickyTable.querySelectorAll("th")];

originalCells.forEach((cell, index) => {
const stickyCell = stickyCells[index];

if (!stickyCell) {
return;
}

const { width } = cell.getBoundingClientRect();
const resolvedWidth = `${Math.round(width)}px`;

stickyCell.style.width = resolvedWidth;
stickyCell.style.minWidth = resolvedWidth;
stickyCell.style.maxWidth = resolvedWidth;
});
};

let frameRequested = false;

const syncStickyHeader = () => {
frameRequested = false;

const headerOffset = Math.ceil(document.querySelector(".ud-header")?.getBoundingClientRect().height || 0);
const wrapperRect = tableWrapper.getBoundingClientRect();
const tableRect = table.getBoundingClientRect();
const tableHeadRect = tableHead.getBoundingClientRect();
const shouldShow = tableHeadRect.top <= headerOffset && tableRect.bottom > headerOffset + tableHeadRect.height;

syncStickyColumnWidths();

stickyHeader.style.top = `${headerOffset}px`;
stickyHeader.style.left = `${wrapperRect.left}px`;
stickyHeader.style.width = `${wrapperRect.width}px`;
stickyTable.style.width = `${table.scrollWidth}px`;
stickyTable.style.transform = `translateX(${-tableWrapper.scrollLeft}px)`;
stickyHeader.classList.toggle("is-visible", shouldShow);
};

const requestSync = () => {
if (frameRequested) {
return;
}

frameRequested = true;
window.requestAnimationFrame(syncStickyHeader);
};

tableWrapper.addEventListener("scroll", requestSync, { passive: true });
window.addEventListener("scroll", requestSync, { passive: true });
window.addEventListener("resize", requestSync);
window.addEventListener("load", requestSync, { once: true });

if (window.ResizeObserver) {
const resizeObserver = new ResizeObserver(requestSync);
resizeObserver.observe(tableWrapper);
resizeObserver.observe(table);
resizeObserver.observe(tableHead);
}

if (document.fonts?.ready) {
document.fonts.ready.then(requestSync).catch(() => {});
}

requestSync();
}

setupPricingComparisonStickyHeader();
})();
Loading
Loading