The place for more technical questions for those who want to create new pagetypes or bespoke functionality.

Smooth scrolling on Bootstrap pages

  • Neil Pollock
  • Onderwerp Auteur
  • Offline
  • Premium lid
  • Premium lid
Meer
8 jaren 7 maanden geleden #4897 door Neil Pollock
Smooth scrolling on Bootstrap pages werd gestart door Neil Pollock
I'm trying to add some smooth srolling to Bootstrap pages (so that clicking the in-page links in the left-hand menu will cause the page to scroll rather than jump to the specific section).

I'm using some jQuery which selects all hashed links and then applies the scroll animation when clicked. It mostly works, except that it breaks the functionality of any carousel image viewers on the page (since they also use hashed links).

Just wondering if there was an easy way around this, other than manually excluding any carousels, e.g.:
Code:
$("a[href^='#']").not('[href="#car0_6"]').not('[href="#car5_1"]').not('[href="#car6_4"]').click(function () ...etc

Graag Inloggen of een account aanmaken deelnemen aan het gesprek.

Meer
8 jaren 7 maanden geleden #4900 door Fay
Beantwoord door Fay in topic Smooth scrolling on Bootstrap pages
Hi Neil

The carousels are in a div with the class 'carousel' so you could probably use this parent class for the exclusion instead of looking at every single link inside it.

e.g. something along the lines of...
Code:
$("a[href^='#']").not('.carousel a').click(function ()...)

Or make sure you're only selecting those in the left menu to begin with:
Code:
$("#contentTable a[href^='#']").click(function ()...)

I haven't tried these out but something along these lines should work
De volgende gebruiker (s) zei dank u: Neil Pollock

Graag Inloggen of een account aanmaken deelnemen aan het gesprek.

  • Neil Pollock
  • Onderwerp Auteur
  • Offline
  • Premium lid
  • Premium lid
Meer
8 jaren 6 maanden geleden #4911 door Neil Pollock
Beantwoord door Neil Pollock in topic Smooth scrolling on Bootstrap pages
Thanks, that's just what I was looking for.

And so simple! I was clearly overthinking the problem...

Graag Inloggen of een account aanmaken deelnemen aan het gesprek.

Moderators: JohnSmith
Tijd voor maken pagina: 0.131 seconden
Copyright © 2026 The Xerte Project.
Xerte logo Apereo logo OSI Logo