feat: dynamic max-height and width (#1)

This commit is contained in:
josc146
2023-03-16 10:18:13 +08:00
parent 804d21a006
commit 91d47a2970
6 changed files with 33 additions and 7 deletions
@@ -1,6 +1,6 @@
export function setElementPositionInViewport(element, x = 0, y = 0) {
const retX = Math.min(window.innerWidth - element.offsetWidth, Math.max(0, x))
const retY = Math.min(window.innerHeight - element.offsetHeight, Math.max(0, y))
const retX = Math.min(Math.max(0, window.innerWidth - element.offsetWidth), Math.max(0, x))
const retY = Math.min(Math.max(0, window.innerHeight - element.offsetHeight), Math.max(0, y))
element.style.left = retX + 'px'
element.style.top = retY + 'px'
return { x: retX, y: retY }