Hey guys, I saw on BricksUltimate plug-in website that they got a “Nestable Slider syncing option” I was wondering why this isn’t a possible native option for Bricks? Would it be possible for Bricks to add the option for 2 different sliders to sync?
In my opinion, it would be great instead of buying a whole plug-in I don’t need just for that option.
Anyway you can use this with new interactions like so.
Place this to Body (footer) scripts on page with sliders:
<script>
function syncSliders(brxParam) {
const source = brxParam?.source.dataset.scriptId || false;
const target = brxParam?.target.dataset.scriptId || false;
if (!source || !target) {
return; // Exit function if either source or target is not available
}
const main = bricksData.splideInstances[source];
const thumb = bricksData.splideInstances[target];
if (main && thumb) {
main.sync(thumb);
}
}
</script>
document.addEventListener('DOMContentLoaded', function () {
function syncSliders() {
// Retrieves the primary and secondary slider elements via their data attributes
const mainSlider = document.querySelector('[data-sync-source="true"]');
const syncSlider = document.querySelector('[data-sync-target="true"]');
if (!mainSlider || !syncSlider) {
console.warn("The primary or secondary sliders were not found.");
return;
}
const mainId = mainSlider.dataset.scriptId;
const targetId = syncSlider.dataset.scriptId;
// Retrieves slider instances in bricksData
const main = bricksData.splideInstances?.[mainId];
const thumb = bricksData.splideInstances?.[targetId];
if (main && thumb) {
main.sync(thumb);
console.log("The sliders have been successfully synchronized.");
} else {
console.warn("Synchronization failed, retry in progress...");
setTimeout(syncSliders, 500);
}
}
syncSliders();
window.addEventListener('resize', syncSliders);
});