Foundation 6 offcanvas toggle jumps to top

746 Views Asked by At

Goodmorning, I wonder if there is a way to prevent Foundation 6's toggle off-canvas from jumping to the top of the page. I notice that this behaviour is also present in official F6 documentation

2

There are 2 best solutions below

0
On BEST ANSWER

I found a temporary solution. In foundation 6, off-canvas options "forceTop" is currently disabled. If you don't want this behaviour, just go to

bower_components/foundation-sites/js/foundation.offcanvas.js

and comment, at line 211

$('body').scrollTop(0);

The rebuild all the assets.

Hope this helps

EDIT If you wish, it was fixed in development version, and you can grab the correct file. Or you can just add

if ( this.options.forceTop ) { $('body').scrollTop(0); }

to yours in order to restore forceTop option.

Cheers

0
On

The easiest way is just use data-force-top=false in your div attributes as below:

<div class="off-canvas position-right" id="offCanvasRight" data-force-top=false data-off-canvas data-position="right">