mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Fixed canvas resizing bug
The canvas size was not being updated after opening a png
This commit is contained in:
parent
93c73f939c
commit
b595026ea8
@ -1102,6 +1102,26 @@ svg {
|
||||
width:400px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
select {
|
||||
height:30px;
|
||||
background-color: $basehover;
|
||||
color: $basehovericon;
|
||||
border:none;
|
||||
position:relative;
|
||||
left:10px;
|
||||
|
||||
option {
|
||||
background-color: $basehover;
|
||||
color:$basehovericon;
|
||||
padding:5px;
|
||||
}
|
||||
|
||||
option:checked, option:hover {
|
||||
background-color: $basehovericon;
|
||||
color:$basehovericonhover;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#rs-keep-ratio {
|
||||
|
@ -184,8 +184,8 @@ class Layer {
|
||||
|
||||
setCanvasOffset (offsetLeft, offsetTop) {
|
||||
//horizontal offset
|
||||
var minXOffset = -this.canvasSize[0] * zoom + 300;
|
||||
var maxXOffset = window.innerWidth - 148;
|
||||
var minXOffset = -this.canvasSize[0] * zoom;
|
||||
var maxXOffset = window.innerWidth - 300;
|
||||
|
||||
if (offsetLeft < minXOffset)
|
||||
this.canvas.style.left = minXOffset +'px';
|
||||
|
@ -39,7 +39,12 @@ function newPixel (width, height, editorMode, fileContent = null) {
|
||||
layers[1] = new Layer(width, height, layers[1].canvas, layers[1].menuEntry);
|
||||
currentLayer = layers[1];
|
||||
|
||||
currentLayer.canvas.style.zIndex = 2;
|
||||
currentLayer.canvas.style.zIndex = 2;
|
||||
|
||||
// Updating canvas size
|
||||
for (let i=0; i<nLayers; i++) {
|
||||
layers[i].canvasSize = [width, height];
|
||||
}
|
||||
}
|
||||
|
||||
// Adding the checkerboard behind it
|
||||
|
@ -1,14 +1,10 @@
|
||||
let resizeCanvasContainer = document.getElementById("resize-canvas");
|
||||
let rcPivot = "middle";
|
||||
let currentPivotObject;
|
||||
let resizeCanvasInitialized = false;
|
||||
let borders = {left: 0, right: 0, top: 0, bottom: 0};
|
||||
|
||||
function openResizeCanvasWindow() {
|
||||
if (!resizeCanvasInitialized) {
|
||||
resizeCanvasInitialized = true;
|
||||
initResizeCanvasInputs();
|
||||
}
|
||||
initResizeCanvasInputs();
|
||||
showDialogue('resize-canvas');
|
||||
}
|
||||
|
||||
|
@ -291,6 +291,13 @@
|
||||
<span>
|
||||
Keep current ratio <input type = "checkbox" id = "rs-keep-ratio"/>
|
||||
</span>
|
||||
<span>
|
||||
Resizing algorithm:
|
||||
<select name = "resize-algorithm">
|
||||
<option value = "nearest-neighbor">Nearest neighbour</option>
|
||||
<option value = "bilinear-interpolation">Bilinear</option>
|
||||
</select>
|
||||
</span>
|
||||
</br>
|
||||
<button id = "resize-sprite-confirm">Resize sprite</button>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user