Merge pull request #140 from KarboniteKream/horizontal-offset
Add horizontal popup offset
This commit is contained in:
commit
84b990cd80
@ -193,7 +193,8 @@ function optionsSetDefaults(options) {
|
|||||||
popupDisplayMode: 'default',
|
popupDisplayMode: 'default',
|
||||||
popupWidth: 400,
|
popupWidth: 400,
|
||||||
popupHeight: 250,
|
popupHeight: 250,
|
||||||
popupOffset: 10,
|
popupHorizontalOffset: 0,
|
||||||
|
popupVerticalOffset: 10,
|
||||||
showGuide: true,
|
showGuide: true,
|
||||||
compactTags: false,
|
compactTags: false,
|
||||||
compactGlossaries: false,
|
compactGlossaries: false,
|
||||||
|
@ -34,7 +34,8 @@ async function formRead() {
|
|||||||
optionsNew.general.popupDisplayMode = $('#popup-display-mode').val();
|
optionsNew.general.popupDisplayMode = $('#popup-display-mode').val();
|
||||||
optionsNew.general.popupWidth = parseInt($('#popup-width').val(), 10);
|
optionsNew.general.popupWidth = parseInt($('#popup-width').val(), 10);
|
||||||
optionsNew.general.popupHeight = parseInt($('#popup-height').val(), 10);
|
optionsNew.general.popupHeight = parseInt($('#popup-height').val(), 10);
|
||||||
optionsNew.general.popupOffset = parseInt($('#popup-offset').val(), 10);
|
optionsNew.general.popupHorizontalOffset = parseInt($('#popup-horizontal-offset').val(), 0);
|
||||||
|
optionsNew.general.popupVerticalOffset = parseInt($('#popup-vertical-offset').val(), 10);
|
||||||
|
|
||||||
optionsNew.scanning.middleMouse = $('#middle-mouse-button-scan').prop('checked');
|
optionsNew.scanning.middleMouse = $('#middle-mouse-button-scan').prop('checked');
|
||||||
optionsNew.scanning.touchInputEnabled = $('#touch-input-enabled').prop('checked');
|
optionsNew.scanning.touchInputEnabled = $('#touch-input-enabled').prop('checked');
|
||||||
@ -166,7 +167,8 @@ async function onReady() {
|
|||||||
$('#popup-display-mode').val(options.general.popupDisplayMode);
|
$('#popup-display-mode').val(options.general.popupDisplayMode);
|
||||||
$('#popup-width').val(options.general.popupWidth);
|
$('#popup-width').val(options.general.popupWidth);
|
||||||
$('#popup-height').val(options.general.popupHeight);
|
$('#popup-height').val(options.general.popupHeight);
|
||||||
$('#popup-offset').val(options.general.popupOffset);
|
$('#popup-horizontal-offset').val(options.general.popupHorizontalOffset);
|
||||||
|
$('#popup-vertical-offset').val(options.general.popupVerticalOffset);
|
||||||
|
|
||||||
$('#middle-mouse-button-scan').prop('checked', options.scanning.middleMouse);
|
$('#middle-mouse-button-scan').prop('checked', options.scanning.middleMouse);
|
||||||
$('#touch-input-enabled').prop('checked', options.scanning.touchInputEnabled);
|
$('#touch-input-enabled').prop('checked', options.scanning.touchInputEnabled);
|
||||||
|
@ -117,8 +117,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group options-advanced">
|
<div class="form-group options-advanced">
|
||||||
<label for="popup-offset">Popup offset (in pixels)</label>
|
<label>Popup offset (horizontal, vertical; in pixels)</label>
|
||||||
<input type="number" min="0" id="popup-offset" class="form-control">
|
<div class="row">
|
||||||
|
<div class="col-xs-6"><input type="number" min="0" id="popup-horizontal-offset" class="form-control"></div>
|
||||||
|
<div class="col-xs-6"><input type="number" min="0" id="popup-vertical-offset" class="form-control"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class Popup {
|
|||||||
const limitX = document.body.clientWidth;
|
const limitX = document.body.clientWidth;
|
||||||
const limitY = window.innerHeight;
|
const limitY = window.innerHeight;
|
||||||
|
|
||||||
let x = elementRect.left;
|
let x = elementRect.left + options.general.popupHorizontalOffset;
|
||||||
let width = Math.max(containerWidth, options.general.popupWidth);
|
let width = Math.max(containerWidth, options.general.popupWidth);
|
||||||
const overflowX = Math.max(x + width - limitX, 0);
|
const overflowX = Math.max(x + width - limitX, 0);
|
||||||
if (overflowX > 0) {
|
if (overflowX > 0) {
|
||||||
@ -65,8 +65,8 @@ class Popup {
|
|||||||
let above = false;
|
let above = false;
|
||||||
let y = 0;
|
let y = 0;
|
||||||
let height = Math.max(containerHeight, options.general.popupHeight);
|
let height = Math.max(containerHeight, options.general.popupHeight);
|
||||||
const yBelow = elementRect.bottom + options.general.popupOffset;
|
const yBelow = elementRect.bottom + options.general.popupVerticalOffset;
|
||||||
const yAbove = elementRect.top - options.general.popupOffset;
|
const yAbove = elementRect.top - options.general.popupVerticalOffset;
|
||||||
const overflowBelow = Math.max(yBelow + height - limitY, 0);
|
const overflowBelow = Math.max(yBelow + height - limitY, 0);
|
||||||
const overflowAbove = Math.max(height - yAbove, 0);
|
const overflowAbove = Math.max(height - yAbove, 0);
|
||||||
if (overflowBelow > 0 || overflowAbove > 0) {
|
if (overflowBelow > 0 || overflowAbove > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user