resize image to fit bounds
This commit is contained in:
@@ -8,16 +8,16 @@ function calculateOffsets() {
|
||||
const yOffset = startYOffset + (currentY - y_start);
|
||||
const xOffset = startXOffset + (currentX - x_start);
|
||||
|
||||
var top = bitmap.height / 2 - yOffset - 175;
|
||||
var top = image_height / 2 - yOffset - 175 - 5;
|
||||
if (top > 0) top = 0;
|
||||
|
||||
var bottom = -(bitmap.height / 2) - yOffset + 10 + 175;
|
||||
var bottom = -(image_height / 2) - yOffset + 5 + 175;
|
||||
if (bottom < 0) bottom = 0;
|
||||
|
||||
var left = bitmap.width / 2 - xOffset - 175;
|
||||
var left = image_width / 2 - xOffset - 175 - 5;
|
||||
if (left > 0) left = 0;
|
||||
|
||||
var right = -(bitmap.width / 2) - xOffset + 10 + 175;
|
||||
var right = -(image_width / 2) - xOffset + 5 + 175;
|
||||
if (right < 0) right = 0;
|
||||
return { x: xOffset + left + right, y: yOffset + top + bottom };
|
||||
}
|
||||
|
||||
@@ -171,11 +171,13 @@
|
||||
|
||||
#new_profile_image {
|
||||
z-index: 1;
|
||||
transform: translateX(calc(-50% + var(--x-offset)))
|
||||
translateY(calc(-50% + var(--y-offset)));
|
||||
transform: translateX(calc(-50% + var(--x-offset) + 5px))
|
||||
translateY(calc(-50% + var(--y-offset) + 5px));
|
||||
position: absolute;
|
||||
left: calc(350px / 2);
|
||||
top: calc(350px / 2);
|
||||
width: var(--x-size);
|
||||
height: var(--y-size);
|
||||
}
|
||||
|
||||
#grab-area {
|
||||
|
||||
Reference in New Issue
Block a user