Download & Extend

Automaic scroll to the top of the block

Project:Accordion Blocks
Version:6.x-1.0-beta2
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

When the block height is bigger than the browser height, the page should scroll to the block header like if there was an anchor to the header, so the user can see the begining of the block and not the end.
Thanks
Julien

Comments

#1

Hi Julien,

Jquery UI accordion widget is not providing this feature by default. You can use following code in your custom module to scroll to selected block header.

Drupal.behaviors.accordion_blocks_customization = function() {
    $('.accordion_blocks_container').bind('accordionchange', function(event, ui){
    var newHeader = ui.newHeader;
    var newOffset = newHeader.offset();
    window.scrollTo(newOffset.left, newOffset.top);
});
}

#2

Use the following code in the accordion_init.js after line 3 . You can set the scroll speed to any variable speed, The following code sets it to 10.

$('html,body').animate({scrollTop:0}, 10, 'ease');