Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. Drupal.behaviors.scrollLinks = {
  2. attach: function (context) {
  3. // Anchor in on the page, must have id="results-anchor"
  4. var $anchor = $('a#results-anchor', context);
  5.  
  6. if ($anchor.length) {
  7. // Link to scroll to anchor, must have class="results-link"
  8. var $resultsLink = $('a.results-link', context);
  9.  
  10. if ($resultsLink.length) {
  11. $resultsLink.on('click', function(e) {
  12. e.preventDefault();
  13. $('html,body').animate({scrollTop: $anchor.offset().top}, 'slow');
  14. })
  15. }
  16. }
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement