Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Added padding when menu opened #129

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,21 @@
.rightClickOpened {
height: 100% !important;
overflow: hidden !important;
padding: 0 12px 0 0;
}
.rightClickOpenedFF {
padding: 0 8px 0 0;
}
.openedHorizontalShift {
padding: 0 12px 0 0;
}
.openedHorizontalShiftFF {
padding: 0 8px 0 0;
}
/* separate padding values for the view-toggle element as it already has padding */
.view-togglePadding {
padding: 22px 46px 22px 22px!important; /* Maths genius */
}
.view-togglePaddingFF {
padding: 22px 38px 22px 22px!important;
}
24 changes: 24 additions & 0 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ var RightClick = RightClick || {};
menuClass: 'rightClickMenu',
subMenuClass: 'rightClickSubMenu',
openedClass: 'rightClickOpened',
openedShiftClass: 'openedHorizontalShift',
openedShiftClassFF: 'openedHorizontalShiftFF',
openedVTPaddingClass: 'view-togglePadding',
openedVTPaddingClassFF: 'view-togglePaddingFF',
arrowClass: 'rightClickArrow',
};
exports.handableKeys = [
Expand Down Expand Up @@ -438,6 +442,18 @@ var RightClick = RightClick || {};
if (!exports.isAMenuOpened()) {
$(window).on('resize', exports.closeAllMenus);
$('body').addClass(exports.selectors.openedClass);
//Add padding to elements to stop page jumping on right click
if(navigator.userAgent.match(/firefox|fxios/i)){ // More if statements can be added for other browsers with elseif
console.log('Match');
$('body').addClass(exports.selectors.openedShiftClassFF);
$('#header').addClass(exports.selectors.openedShiftClassFF);
$('#view-toggle').addClass(exports.selectors.openedVTPaddingClassFF);
} else {
console.log('No match');
$('#header').addClass(exports.selectors.openedShiftClass);
$('body').addClass(exports.selectors.openedShiftClass);
$('#view-toggle').addClass(exports.selectors.openedVTPaddingClass);
}
}

$('#' + exports.selectors.detectorId).css('display', 'block');
Expand Down Expand Up @@ -466,6 +482,14 @@ var RightClick = RightClick || {};
if (!exports.isAMenuOpened()) {
$(window).off('resize', exports.closeAllMenus);
$('body').removeClass(exports.selectors.openedClass);
//Remove padding shift classes
$('#header').removeClass(exports.selectors.openedShiftClass);
$('body').removeClass(exports.selectors.openedShiftClass);
$('#view-toggle').removeClass(exports.selectors.openedVTPaddingClass);
//Specific for Firefox
$('#header').removeClass(exports.selectors.openedShiftClassFF);
$('body').removeClass(exports.selectors.openedShiftClassFF);
$('#view-toggle').removeClass(exports.selectors.openedVTPaddingClassFF);
$('#' + exports.selectors.detectorId).css('display', 'none');

return true;
Expand Down