Version bump [ci-build]

Fix menu scrolling on mobile
Fix padding not working on mesh templates
This commit is contained in:
JannisX11 2022-03-20 16:07:32 +01:00
parent fa6e3b44c3
commit b48b4702d3
3 changed files with 46 additions and 11 deletions

View File

@ -3,17 +3,37 @@ var open_menu = null;
function handleMenuOverflow(node) {
node = node.get(0);
if (!node) return;
// Todo: mobile support
node.addEventListener('wheel', e => {
e.stopPropagation();
function offset(amount) {
let top = parseInt(node.style.top);
let offset = top - $(node).offset().top;
top = Math.clamp(
top - e.deltaY,
top + amount,
window.innerHeight - node.clientHeight + offset,
offset + 26
);
node.style.top = `${top}px`;
}
if (Blockbench.isTouch) {
node.addEventListener('touchstart', e1 => {
e1.stopPropagation();
convertTouchEvent(e1);
let last_y = e1.clientY;
let move = e2 => {
convertTouchEvent(e2);
offset(e2.clientY - last_y);
last_y = e2.clientY;
}
let stop = e2 => {
document.removeEventListener('touchmove', move);
document.removeEventListener('touchend', stop);
}
document.addEventListener('touchmove', move);
document.addEventListener('touchend', stop);
})
}
node.addEventListener('wheel', e => {
e.stopPropagation();
offset(-e.deltaY);
})
}
class Menu {

View File

@ -1105,14 +1105,29 @@ const TextureGenerator = {
function forTemplatePixel(tpl, sx, sy, cb) {
let w = tpl.width;
let h = tpl.height;
if (options.padding) {
w++; h++;
}
for (var x = 0; x < w; x++) {
if (tpl.matrix && !tpl.matrix[x]) continue;
for (var y = 0; y < h; y++) {
if (tpl.matrix && !tpl.matrix[x][y]) continue;
if (cb(sx+x, sy+y)) return;
for (var x = 0; x < w; x++) {
if (tpl.matrix && !tpl.matrix[x] && !tpl.matrix[x-1]) continue;
for (var y = 0; y < h; y++) {
if (
tpl.matrix &&
(!tpl.matrix[x] || !tpl.matrix[x][y]) &&
(!tpl.matrix[x-1] || !tpl.matrix[x-1][y]) &&
(!tpl.matrix[x] || !tpl.matrix[x][y-1]) &&
(!tpl.matrix[x-1] || !tpl.matrix[x-1][y-1])
) continue;
if (cb(sx+x, sy+y)) return;
}
}
} else {
for (var x = 0; x < w; x++) {
if (tpl.matrix && !tpl.matrix[x]) continue;
for (var y = 0; y < h; y++) {
if (tpl.matrix && !tpl.matrix[x][y]) continue;
if (cb(sx+x, sy+y)) return;
}
}
}
}

View File

@ -1,7 +1,7 @@
{
"name": "Blockbench",
"description": "Low-poly modeling and animation software",
"version": "4.2.0-beta.1",
"version": "4.2.0-beta.2",
"license": "GPL-3.0-or-later",
"author": {
"name": "JannisX11",