Skip to content

Commit

Permalink
First try to fix issues with smoothscroll and mobile browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
JoryHogeveen committed Oct 5, 2016
1 parent 92cc125 commit c2bf5d2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
21 changes: 20 additions & 1 deletion css/off-canvas-sidebars.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,28 @@
*
* @author Jory Hogeveen <[email protected]>
* @package off-canvas-sidebars
* @version 0.3
* @version 0.3.2
*/

/**
* Slidebar CSS overwrites
*/

html,
.ocs-initialized html {
overflow-y: auto;
height: auto;
}
[canvas=container],
.ocs-initialized [canvas=container] {
overflow-y: hidden;
height: auto;
}

html.ocs-scroll-lock {
overflow-y: hidden;
}

/**
* Sidebar Widths (patched from older version of Slidebars)
*/
Expand Down
14 changes: 13 additions & 1 deletion js/off-canvas-sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* ocsOffCanvasSidebars
* @author Jory Hogeveen <[email protected]>
* @package off-canvas-sidebars
* @version 0.3
* @version 0.3.2
* @global ocsOffCanvasSidebars
*/

Expand All @@ -23,10 +23,14 @@ if ( typeof ocsOffCanvasSidebars == 'undefined' ) {

ocsOffCanvasSidebars.slidebarsController = false;
ocsOffCanvasSidebars.useAttributeSettings = false;
ocsOffCanvasSidebars.container = false;
ocsOffCanvasSidebars._html = $( 'html' );
ocsOffCanvasSidebars._touchmove = false;

ocsOffCanvasSidebars.init = function() {

ocsOffCanvasSidebars.container = $( '[canvas=container]' );

/**
* Function call before initializing
* @since 0.3
Expand All @@ -44,6 +48,8 @@ if ( typeof ocsOffCanvasSidebars == 'undefined' ) {
// Initialize slidebars
ocsOffCanvasSidebars.slidebarsController.init();

ocsOffCanvasSidebars._html.addClass('ocs-initialized');

/**
* Function call after initializing
* @since 0.3
Expand Down Expand Up @@ -255,11 +261,17 @@ if ( typeof ocsOffCanvasSidebars == 'undefined' ) {
// Add close class to canvas container when Slidebar is opened
$( controller.events ).on( 'opening', function () {
$( '[canvas]' ).addClass( prefix + '-close-any' );
ocsOffCanvasSidebars._html.addClass( 'ocs-sidebar-active' );
if ( ocsOffCanvasSidebars._getSetting( 'scroll_lock' ) ) {
ocsOffCanvasSidebars._html.addClass( 'ocs-scroll-lock' );
}
} );

// Add close class to canvas container when Slidebar is opened
$( controller.events ).on( 'closing', function () {
$( '[canvas]' ).removeClass( prefix + '-close-any' );
ocsOffCanvasSidebars._html.removeClass( 'ocs-sidebar-active' );
ocsOffCanvasSidebars._html.removeClass( 'ocs-scroll-lock' );
} );


Expand Down

0 comments on commit c2bf5d2

Please sign in to comment.