alvarotrigo / alvarotrigo/pagePiling.js

Create dynamic anchors on load

Open
#209 3 comments 0 reactions 0 assignees View on GitHub
reproduction required
Dominant language
JavaScript
Stars
4.1k
Forks
633
PR merge metrics
No merged PRs in 30d

Description

Hello. I have a problem, similar to some of the others who I've read this before.

It's about the anchors. Since I wanted mine to be dynamic with Laravel, I pack the entire pagepiling as @push ('scripts_footer') and then let it load as soon as the dom is ready.
So far so good.
Now I wanted to set the anchors dynamically. To do this, I go to the navigation when building the page and pack the ids in a Laravel variable, which I then insert via @stack on pagepiling.
This also works, but not if you try to call the anchor via a link. But only on Firefox and some other browsers. On Chrome, for example, it works. Is there an alternative way to do this?

$('.pagepiling').pagepiling({
scrollingSpeed: 280,
loopBottom: false,
keyboardScrolling: true,
anchors: [@stack('anchors')],
menu: '#anchor_subnav',
afterRender: function() {
$('#pp-nav').addClass('change');
},
afterLoad: function (anchorLink, index) {
if (index >= 2) {
$('.logo').removeClass('d-block').addClass('d-none');
$('.logo-dark').removeClass('d-none').addClass('d-block');
$('.open-menu').addClass('change');
$('#pp-nav').removeClass('change');
}

if (index == 1) {
$('.logo').removeClass('d-none').addClass('d-block');
$('.logo-dark').removeClass('d-block').addClass('d-none');
$('.open-menu').removeClass('change');
$('#pp-nav').addClass('change');
}

if (index == sections) {
$('footer').addClass('active');
} else {
$('footer').removeClass('active');
}
},
});

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.