How to alter default ajax_view default ScrollTop? In ajax_view.js, the code responsible of smooth Ajax View ScrollTop when changing the exposed filters is the following :

Drupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response, status) {
  // Scroll to the top of the view. This will allow users
  // to browse newly loaded content after e.g. clicking a pager
  // link.
  var offset = $(response.selector).offset();
  // We can't guarantee that the scrollable object should be
  // the body, as the view could be embedded in something
  // more complex such as a modal popup. Recurse up the DOM
  // and scroll the first element that has a non-zero top.
  var scrollTarget = response.selector;
  while ($(scrollTarget).scrollTop() == 0 &amp;&amp; $(scrollTarget).parent()) {
    scrollTarget = $(scrollTarget).parent();
  }
  // Only scroll upward
  if (offset.top - 100 &lt; $(scrollTarget).scrollTop()) {
    $(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500);
  }
};

})(jQuery);


I tried to alter this behaviour from a custom module, but no way to get it working. How can I proper change the values of offset.top - 10 to offset.top - 100 ? Here's one of my several tries...

function MYMODULE_init() {
  drupal_add_js( drupal_get_path('theme', 'MYTHEME').'/assets/js/MYSCRIPT.js');
  //...

//IN MYSCRIPT.js
Drupal.behaviors.events = {
  attach: function(context, settings) {
    $('.my_view', context).ajaxStart(function(){
      $('.my_view', context).fadeTo(500, 0.7);//this works
    });
    $('.my_view', context).ajaxSuccess(function(){
      $('.my_view', context).fadeTo(300, 1)//this works
          .animate({scrollTop: (offset.top - 100)}, 500);//this doesn't
  //...
As @Clive mentioned it is because your JS order load is wrong(your JS loaded before than views JS)
I suggest you instead add JS in hook_init put it in hook_form_alter or in hook_page_preprocess 

drupal_add_js( drupal_get_path('theme', 'MYTHEME').'/assets/js/MYSCRIPT.js',array(
            'type' =&gt; 'file',
            'scope' =&gt; 'footer',
            'weight' =&gt; 100,
        )
);