Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Displace" option given ability to squish body. #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 17 additions & 21 deletions src/jquery.sidr.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
displace = $menu.data('displace'),
onOpen = $menu.data('onOpen'),
onClose = $menu.data('onClose'),
bodyAnimation,
menuAnimation,
bodyAnimation = {},
menuAnimation = {},
scrollTop,
bodyClass = (name === 'sidr' ? 'sidr-open' : 'sidr-open ' + name + '-open');

Expand All @@ -89,15 +89,13 @@
// Lock sidr
sidrMoving = true;

// Left or right?
if(side === 'left') {
bodyAnimation = {left: menuWidth + 'px'};
menuAnimation = {left: '0px'};
}
else {
bodyAnimation = {right: menuWidth + 'px'};
menuAnimation = {right: '0px'};
//Set up displacement
if(displace == 'slide' || displace == 'squish') {
bodyAnimation[side] = menuWidth + 'px';
if(displace == 'squish')
bodyAnimation['width'] = $body.width() - menuWidth;
}
menuAnimation[side] = '0px';

// Prepare page if container is body
if($body.is('body')){
Expand All @@ -106,7 +104,7 @@
}

// Open menu
if(displace){
if(displace == 'slide' || displace == 'squish') {
$body.addClass('sidr-animating').css({
width: $body.width(),
position: 'absolute'
Expand Down Expand Up @@ -142,15 +140,13 @@
// Lock sidr
sidrMoving = true;

// Right or left menu?
if(side === 'left') {
bodyAnimation = {left: 0};
menuAnimation = {left: '-' + menuWidth + 'px'};
}
else {
bodyAnimation = {right: 0};
menuAnimation = {right: '-' + menuWidth + 'px'};
}
//Set up displacement
if(displace == 'slide' || displace == 'squish') {
bodyAnimation[side] = 0;
if(displace == 'squish')
bodyAnimation['width'] = $body.width() + menuWidth;
}
menuAnimation[side] = '-' + menuWidth + 'px';

// Close menu
if($body.is('body')){
Expand Down Expand Up @@ -217,7 +213,7 @@
source : null, // Override the source of the content.
renaming : true, // The ids and classes will be prepended with a prefix when loading existent content
body : 'body', // Page container selector,
displace: true, // Displace the body content or not
displace: 'shift', // Displace the body content or not
onOpen : function() {}, // Callback when sidr opened
onClose : function() {} // Callback when sidr closed
}, options);
Expand Down