- Issue created by @socalerich
- π·πΊRussia kostyashupenko Omsk
Normal way is to extend library in `themename.info.yml`:
libraries-extend: views/views.ajax: - my_theme/views.ajax
Then declare new drupal library in `themename.libraries.yml`
views.ajax: js: path/to/your/js/file/override.js: {}
and then in js file you can override
Drupal.AjaxCommands.prototype.viewsScrollTop = function (ajax, response) {
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/views...
Here you can do whatever you need
- Status changed to Closed: won't fix
over 1 year ago 7:47am 31 July 2023 - πΊπΈUnited States socalerich
Just in case anyone else ends up having this issue, I followed the steps above and this was my JavaScript that ended up working as far as the override goes. One note is that the "header_height" variable is dependent on what your projects actual header height is, so you may need to adjust that.
(function ($, Drupal) { Drupal.AjaxCommands.prototype.scrollTop = function (ajax, response) { var offset = $(response.selector).offset(); var scrollTarget = response.selector; while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) { scrollTarget = $(scrollTarget).parent(); } var header_height = 200; if (offset.top - header_height < $(scrollTarget).scrollTop()) { $(scrollTarget).animate({ scrollTop: offset.top - header_height }, 500); } }; })(jQuery, Drupal);