mirror of
https://github.com/picocss/pico.git
synced 2025-04-23 09:56:14 -04:00
Import Most Visible library
This commit is contained in:
parent
8cb28b3707
commit
4a2e9714f3
5 changed files with 16 additions and 5 deletions
|
@ -11,6 +11,7 @@
|
|||
export const scrollspy = {
|
||||
|
||||
// Config
|
||||
mostVisible: null,
|
||||
minWidth: '992px',
|
||||
interval: 75,
|
||||
targets: {
|
||||
|
@ -21,7 +22,10 @@ export const scrollspy = {
|
|||
|
||||
|
||||
// Init
|
||||
init() {
|
||||
init(mostVisible) {
|
||||
if (this.mostVisible == null) {
|
||||
this.mostVisible = mostVisible;
|
||||
}
|
||||
if (window.matchMedia('(min-width: ' + this.minWidth + ')').matches) {
|
||||
this.setActiveNav();
|
||||
this.scrollStop();
|
||||
|
@ -33,7 +37,7 @@ export const scrollspy = {
|
|||
setActiveNav() {
|
||||
|
||||
// Get active section
|
||||
let currentSection = mostVisible(this.targets.sections).getAttribute('id');
|
||||
let currentSection = this.mostVisible(this.targets.sections).getAttribute('id');
|
||||
|
||||
// Remove all active states
|
||||
let links = document.querySelectorAll(this.targets.nav + ' a.' + this.targets.active);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue