fixed size

This commit is contained in:
2024-09-21 00:50:49 +02:00
parent 11f8b42b79
commit a7ec470da1
3 changed files with 92 additions and 56 deletions

View File

@@ -44752,6 +44752,33 @@
transparent: true, transparent: true,
resizeTo: window resizeTo: window
}); });
// function to read json file
function readJSON(path) {
return new Promise((resolve, reject) => {
fetch(path)
.then(response => response.json())
.then(data => resolve(data))
.catch(error => reject(error));
});
}
function draggable(model) {
model.buttonMode = true;
model.on("pointerdown", (e) => {
model.dragging = true;
model._pointerX = e.data.global.x - model.x;
model._pointerY = e.data.global.y - model.y;
});
model.on("pointermove", (e) => {
if (model.dragging) {
model.position.x = e.data.global.x - model._pointerX;
model.position.y = e.data.global.y - model._pointerY;
}
});
model.on("pointerupoutside", () => (model.dragging = false));
model.on("pointerup", () => (model.dragging = false));
}
const model = await Live2DModel.from(jsonpath); const model = await Live2DModel.from(jsonpath);
app.stage.addChild(model); app.stage.addChild(model);
@@ -44766,7 +44793,7 @@
// Align bottom and center horizontally // Align bottom and center horizontally
model.x = (parentWidth - model.width) / 2; model.x = (parentWidth - model.width) / 2;
model.y = parentHeight - model.height; model.y = parentHeight - model.height;
draggable(model);
// read json file to find motion groups // read json file to find motion groups
let modelJson = await readJSON(`${jsonpath}`); let modelJson = await readJSON(`${jsonpath}`);
@@ -44779,15 +44806,6 @@
} }
}); });
// function to read json file
function readJSON(path) {
return new Promise((resolve, reject) => {
fetch(path)
.then(response => response.json())
.then(data => resolve(data))
.catch(error => reject(error));
});
}
} }
} }

View File

@@ -232,6 +232,33 @@ function loadWidget() {
transparent: true, transparent: true,
resizeTo: window resizeTo: window
}); });
// function to read json file
function readJSON(path) {
return new Promise((resolve, reject) => {
fetch(path)
.then(response => response.json())
.then(data => resolve(data))
.catch(error => reject(error));
});
}
function draggable(model) {
model.buttonMode = true;
model.on("pointerdown", (e) => {
model.dragging = true;
model._pointerX = e.data.global.x - model.x;
model._pointerY = e.data.global.y - model.y;
});
model.on("pointermove", (e) => {
if (model.dragging) {
model.position.x = e.data.global.x - model._pointerX;
model.position.y = e.data.global.y - model._pointerY;
}
});
model.on("pointerupoutside", () => (model.dragging = false));
model.on("pointerup", () => (model.dragging = false));
}
const model = await Live2DModel.from(jsonpath); const model = await Live2DModel.from(jsonpath);
app.stage.addChild(model); app.stage.addChild(model);
@@ -246,7 +273,7 @@ function loadWidget() {
// Align bottom and center horizontally // Align bottom and center horizontally
model.x = (parentWidth - model.width) / 2; model.x = (parentWidth - model.width) / 2;
model.y = parentHeight - model.height; model.y = parentHeight - model.height;
draggable(model);
// read json file to find motion groups // read json file to find motion groups
let modelJson = await readJSON(`${jsonpath}`); let modelJson = await readJSON(`${jsonpath}`);
@@ -259,15 +286,6 @@ function loadWidget() {
} }
}); });
// function to read json file
function readJSON(path) {
return new Promise((resolve, reject) => {
fetch(path)
.then(response => response.json())
.then(data => resolve(data))
.catch(error => reject(error));
});
}
} }
} }

View File

@@ -42,7 +42,8 @@
position: fixed; position: fixed;
transform: translateY(3px); transform: translateY(3px);
transition: transform .3s ease-in-out, bottom 3s ease-in-out; transition: transform .3s ease-in-out, bottom 3s ease-in-out;
z-index: 1; width: 25%;
height: 25%;
} }
#waifu:hover { #waifu:hover {
@@ -98,10 +99,9 @@
#waifu #live2d { #waifu #live2d {
cursor: grab; cursor: grab;
height: 280px; height: 100%;
position: relative; position: relative;
width: 330px; width: 100%;
/* z-index: -1; */
} }
#waifu #live2d:active { #waifu #live2d:active {