Supporting each other

Community forums

Welcome, Guest
Username: Password: Remember me
The place for more technical questions for those who want to create new pagetypes or bespoke functionality.
  • Page:
  • 1

TOPIC:

Smooth scrolling on Bootstrap pages 6 years 10 months ago #4897

  • Neil Pollock
  • Neil Pollock's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 92
  • Thank you received: 4
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.:
$("a[href^='#']").not('[href="#car0_6"]').not('[href="#car5_1"]').not('[href="#car6_4"]').click(function () ...etc

Please Log in or Create an account to join the conversation.

Smooth scrolling on Bootstrap pages 6 years 10 months ago #4900

  • Fay
  • Fay's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • Posts: 229
  • Thank you received: 92
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...
$("a[href^='#']").not('.carousel a').click(function ()...)

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

I haven't tried these out but something along these lines should work
The following user(s) said Thank You: Neil Pollock

Please Log in or Create an account to join the conversation.

Smooth scrolling on Bootstrap pages 6 years 9 months ago #4911

  • Neil Pollock
  • Neil Pollock's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 92
  • Thank you received: 4
Thanks, that's just what I was looking for.

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

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: JohnSmith
Time to create page: 0.044 seconds
Copyright © 2024 The Xerte Project.
Xerte logo Apereo logo OSI Logo

Search