clamp, button fix
This commit is contained in:
parent
2f555f881b
commit
55275ba9be
@ -68,7 +68,6 @@ export class ViewCanvas {
|
|||||||
public moveCursor(): void {
|
public moveCursor(): void {
|
||||||
this._resetPlacerTag();
|
this._resetPlacerTag();
|
||||||
|
|
||||||
// Zoom multiplier
|
|
||||||
// Apparent size of the canvas after scaling it
|
// Apparent size of the canvas after scaling it
|
||||||
const realSize = this._zoom * this._size;
|
const realSize = this._zoom * this._size;
|
||||||
// The difference between the real canvas size and apparent size
|
// The difference between the real canvas size and apparent size
|
||||||
@ -85,8 +84,16 @@ export class ViewCanvas {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Position of the cursor on the canvas
|
// Position of the cursor on the canvas
|
||||||
this._relcursorx = Math.floor((this._cursorx - screenX) / this._zoom);
|
this._relcursorx = clamp(
|
||||||
this._relcursory = Math.floor((this._cursory - screenY) / this._zoom);
|
Math.floor((this._cursorx - screenX) / this._zoom),
|
||||||
|
0,
|
||||||
|
this._size - 1,
|
||||||
|
);
|
||||||
|
this._relcursory = clamp(
|
||||||
|
Math.floor((this._cursory - screenY) / this._zoom),
|
||||||
|
0,
|
||||||
|
this._size - 1,
|
||||||
|
);
|
||||||
|
|
||||||
this._screencursorx = this._relcursorx * this._zoom + screenX;
|
this._screencursorx = this._relcursorx * this._zoom + screenX;
|
||||||
this._screencursory = this._relcursory * this._zoom + screenY;
|
this._screencursory = this._relcursory * this._zoom + screenY;
|
||||||
@ -101,7 +108,7 @@ export class ViewCanvas {
|
|||||||
|
|
||||||
this._updateURL();
|
this._updateURL();
|
||||||
|
|
||||||
if (this._zoom > 30) {
|
if (this._zoom > 20) {
|
||||||
this._getPlacerAt(this._relcursorx, this._relcursory);
|
this._getPlacerAt(this._relcursorx, this._relcursory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,11 +420,11 @@ export class ViewCanvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (obj.get('px')) {
|
if (obj.get('px')) {
|
||||||
this._relcursorx = clamp(parseInt(obj.get('px'), 10), 0, this._size);
|
this._relcursorx = clamp(parseInt(obj.get('px'), 10), 0, this._size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.get('py')) {
|
if (obj.get('py')) {
|
||||||
this._relcursory = clamp(parseInt(obj.get('py'), 10), 0, this._size);
|
this._relcursory = clamp(parseInt(obj.get('py'), 10), 0, this._size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._cursorx = this._viewWidth / 2;
|
this._cursorx = this._viewWidth / 2;
|
||||||
|
@ -133,6 +133,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__colors {
|
&__colors {
|
||||||
|
flex-wrap: wrap;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
counter-reset: colorindex;
|
counter-reset: colorindex;
|
||||||
|
|
||||||
@ -167,12 +168,15 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.btn-palette.pickable {
|
.btn-palette.pickable {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
content: '';
|
content: '';
|
||||||
width: 10px;
|
width: 10px;
|
||||||
height: 10px;
|
height: 10px;
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
margin-bottom: -1px;
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
background-color: var(--pick-color);
|
background-color: var(--pick-color);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user