1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-26 22:28:18 +00:00

Problem: revealed dropdown menu on mobiles (#3491)

On mobile phones, tiddler's dropdown menu stays partially off-screen.

Solution: ensure that the revealed coordinates are never negative

Closes #3486
This commit is contained in:
Yurii Rashkovskii 2018-10-21 08:53:45 -07:00 committed by Jeremy Ruston
parent b95f6b523b
commit c0c1b557eb

View File

@ -58,23 +58,23 @@ RevealWidget.prototype.positionPopup = function(domNode) {
domNode.style.zIndex = "1000"; domNode.style.zIndex = "1000";
switch(this.position) { switch(this.position) {
case "left": case "left":
domNode.style.left = (this.popup.left - domNode.offsetWidth) + "px"; domNode.style.left = Math.max(0, this.popup.left - domNode.offsetWidth) + "px";
domNode.style.top = this.popup.top + "px"; domNode.style.top = this.popup.top + "px";
break; break;
case "above": case "above":
domNode.style.left = this.popup.left + "px"; domNode.style.left = this.popup.left + "px";
domNode.style.top = (this.popup.top - domNode.offsetHeight) + "px"; domNode.style.top = Math.max(0, this.popup.top - domNode.offsetHeight) + "px";
break; break;
case "aboveright": case "aboveright":
domNode.style.left = (this.popup.left + this.popup.width) + "px"; domNode.style.left = (this.popup.left + this.popup.width) + "px";
domNode.style.top = (this.popup.top + this.popup.height - domNode.offsetHeight) + "px"; domNode.style.top = Math.max(0, this.popup.top + this.popup.height - domNode.offsetHeight) + "px";
break; break;
case "right": case "right":
domNode.style.left = (this.popup.left + this.popup.width) + "px"; domNode.style.left = (this.popup.left + this.popup.width) + "px";
domNode.style.top = this.popup.top + "px"; domNode.style.top = this.popup.top + "px";
break; break;
case "belowleft": case "belowleft":
domNode.style.left = (this.popup.left + this.popup.width - domNode.offsetWidth) + "px"; domNode.style.left = Math.max(0, this.popup.left + this.popup.width - domNode.offsetWidth) + "px";
domNode.style.top = (this.popup.top + this.popup.height) + "px"; domNode.style.top = (this.popup.top + this.popup.height) + "px";
break; break;
default: // Below default: // Below