Position correctly when near the right edge of window
parent
af25b26fe8
commit
439a672aab
|
@ -3,7 +3,7 @@
|
|||
* Creates a calendar widget which can be used to select the date more easily than using just a text box
|
||||
*
|
||||
* Modified: http://yourcmc.ru/git/vitalif-js/calendar
|
||||
* Version: 2018-10-09
|
||||
* Version: 2018-10-23
|
||||
* License: MIT-like, http://www.openjs.com/license.php
|
||||
*
|
||||
* Example:
|
||||
|
@ -55,8 +55,13 @@ export class Calendar extends preact.Component
|
|||
var div = Calendar.box;
|
||||
var xy = getOffset(input);
|
||||
var height = input.clientHeight||input.offsetHeight;
|
||||
div.style.left = (xy.left-1)+"px";
|
||||
if (div.offsetHeight + xy.top+height-1 >= (document.body.clientHeight||document.documentElement.clientHeight) &&
|
||||
var ww = document.body.clientWidth||document.documentElement.clientWidth;
|
||||
var wh = document.body.clientHeight||document.documentElement.clientHeight;
|
||||
if (xy.left-1+div.offsetWidth > ww)
|
||||
div.style.left = (ww-div.offsetWidth-1)+"px";
|
||||
else
|
||||
div.style.left = (xy.left-1)+"px";
|
||||
if (div.offsetHeight + xy.top+height-1 >= wh &&
|
||||
xy.top-div.offsetHeight >= 0)
|
||||
div.style.top = (xy.top-div.offsetHeight)+'px';
|
||||
else
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* Original: http://www.openjs.com/scripts/ui/calendar/
|
||||
* Modified: http://yourcmc.ru/git/vitalif-js/calendar
|
||||
* Version: 2018-03-17
|
||||
* Version: 2018-10-23
|
||||
* License: MIT-like, http://www.openjs.com/license.php
|
||||
*
|
||||
* Example:
|
||||
|
@ -292,8 +292,12 @@ export class Calendar
|
|||
var div = Calendar.box;
|
||||
var xy = getOffset(input);
|
||||
var height = input.clientHeight||input.offsetHeight;
|
||||
var ww = document.documentElement.clientWidth||document.body.clientWidth;
|
||||
div.style.display = "block";
|
||||
div.style.left = (xy.left-1)+"px";
|
||||
if (div.offsetWidth + xy.left-1 > ww)
|
||||
div.style.left = (ww-div.offsetWidth-1)+"px";
|
||||
else
|
||||
div.style.left = (xy.left-1)+"px";
|
||||
if (div.offsetHeight + xy.top+height-1 >= (document.documentElement.clientHeight||document.body.clientHeight) &&
|
||||
xy.top-div.offsetHeight >= 0)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue