Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The current implementation of the "Anchors" JavaScript is rather hack-ish at best and completely un-configurable at worst. This causes conflicts with existing plugins that implement their own click handlers on <a>
elements that contain a hash (#).
Proposed resolution
Implement support for http://bootstrap-anchor.com
Remaining tasks
Create plugin.Done - It's currently a separate repository located at https://github.com/markcarver/bootstrap-anchor- Commit plugin to this project's repository
- Modify the admin settings UI to allow easier overrides via theme settings
Comment | File | Size | Author |
---|---|---|---|
#14 | replace_custom_js_with-2462645-14.patch | 35.18 KB | neardark |
#4 | replace_custom_js_with-2462645-4.patch | 20.44 KB | markhalliwell |
Comments
Comment #1
markhalliwellOk, I've gone ahead and create the following plugin https://github.com/markcarver/bootstrap-anchor
You can view a demonstration of this plugin in action at http://bootstrap-anchor.com
Once the above remaining tasks are complete, I'll mark this issue as fixed and then release
7.x-3.1-beta3
so people can test it out much easier.If need be, we can always revert whatever is committed in this issue. However, I imagine this is far superior than what is currently in the project.
Instead of creating issues here, please create them over at https://github.com/markcarver/bootstrap-anchor/issues (for now).
My ultimate goal/desire is to actually have this be an official Bootstrap plugin that ships with the framework itself. When/if that happens, we can remove the plugin from this project.
Comment #2
kingfisher64 CreditAttribution: kingfisher64 commentedI was looking for this feature - very cool indeed.
I'll gladly test it out if that will help.
Comment #3
markhalliwellAdded custom domain for plugin.
Comment #4
markhalliwellComment #5
neardark CreditAttribution: neardark as a volunteer commented'),
The smooth
data-smooth
could use a slight bit more explanation for beginners, such as "For smooth scrolling for individual anchors, add data-smooth to your code. Or perhaps just linking to the docs on the site.That's the only thing I saw if you deem worth fixing up, otherwise it looks good and I'll merge it by end of day.
Comment #6
markhalliwell@neardark, sorry. The above patch indeed "needs work", this was just what I had started to do. There are a ton more options that need to be added into the UI.
Comment #7
neardark CreditAttribution: neardark as a volunteer commentedAhh of course. Working on this now then.
Comment #8
sonicthoughts CreditAttribution: sonicthoughts as a volunteer commentedstumbled on this as it was what i needed but the demo is not working for me in chrome (nothing on console). Anchors not working at all at http://bootstrap-anchor.com.
Comment #9
neardark CreditAttribution: neardark as a volunteer commentedHere's a start. Some notes:
Comment #10
neardark CreditAttribution: neardark as a volunteer commentedComment #11
neardark CreditAttribution: neardark as a volunteer commentedComment #12
neardark CreditAttribution: neardark as a volunteer commentedOK, this is ready for some testing by anyone willing. You should note that a few options don't appear to be working, such as Normalize IDs and Anchor Offset. Will investigate further.
I did not commit Bootstrap Anchor to this repo -- instead the installation is for users to download and install Drupal libraries module and then place the Bootstrap Anchor in the sites/all/libraries (or anywhere in sites/* I suppose)
Comment #14
neardark CreditAttribution: neardark as a volunteer commentedNow with libraries.inc
Comment #15
neardark CreditAttribution: neardark as a volunteer commentedComment #16
markhalliwellDiscussed this with @neardark in IRC. This issue really deserves to be fully flushed out (which neither of us really have time for right now). It shouldn't be rushed and shouldn't block a release.
We need a better way to implement "plugins" as a whole: not just for bootstrap-anchor, but also for others like bootstrap-select and bootstrap-datepicker.
Postponing this issue on the parent issue.
Comment #18
markhalliwellI've disabled the existing corrupt plugin by default (for new installations or sites that don't have saved settings in the DB or .info file).
If you need to enable/disable this feature, add the following to your .info file:
Comment #20
N20 CreditAttribution: N20 commentedI tried to enable the settings in my info file without any effect:
I'm using bootstrap-7.x-3.1
Do i need to install that plugin in libraries?
Comment #21
markhalliwellPlease read: Why are my sub-theme's .info settings ignored?
Comment #22
N20 CreditAttribution: N20 commenteddrush vdel theme_[my_bootstrap_subtheme]_settings
worked. Thanks.Comment #23
kumkum29 CreditAttribution: kumkum29 commentedHello,
I have enabled these settings of my info file :
and see in the settings of my theme that these options are enabled.
But if I use an anchor, I don't see the "Smooth effect". Maybe Have I omitted anything ?
Thanks for your replies.
Comment #24
markhalliwellI don't think this is going to happen in 7.x.
Comment #25
markhalliwellComment #26
markhalliwellDon't think this is going to happen for 8.x-3.x either.
Comment #27
jcnventura CreditAttribution: jcnventura at Wunder commentedInstead of
drush vdel
which will destroy your current settings you can also usewhere
[my_bootstrap_subtheme]
is the name of your bootstrap sub-theme.Comment #29
Freddy RodriguezJust Css:
html{scroll-behavior:smooth}
Comment #30
markhalliwellYeah, the plugin does a lot more than just smooth scrolling.
Comment #31
shelaneThis theme will not be supported for Bootstrap 4. See alternative themes for this support.