mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Added layer focus when it's hovered in the menu
This commit is contained in:
parent
8d033778a5
commit
b6d4544cd8
20
js/_layer.js
20
js/_layer.js
@ -57,6 +57,8 @@ class Layer {
|
|||||||
if (menuEntry != null) {
|
if (menuEntry != null) {
|
||||||
this.name = menuEntry.getElementsByTagName("p")[0].innerHTML;
|
this.name = menuEntry.getElementsByTagName("p")[0].innerHTML;
|
||||||
menuEntry.id = "layer" + id;
|
menuEntry.id = "layer" + id;
|
||||||
|
menuEntry.onmouseover = () => this.hover();
|
||||||
|
menuEntry.onmouseout = () => this.unhover();
|
||||||
menuEntry.onclick = () => this.selectLayer();
|
menuEntry.onclick = () => this.selectLayer();
|
||||||
menuEntry.getElementsByTagName("button")[0].onclick = () => this.toggleLock();
|
menuEntry.getElementsByTagName("button")[0].onclick = () => this.toggleLock();
|
||||||
menuEntry.getElementsByTagName("button")[1].onclick = () => this.toggleVisibility();
|
menuEntry.getElementsByTagName("button")[1].onclick = () => this.toggleVisibility();
|
||||||
@ -100,6 +102,24 @@ class Layer {
|
|||||||
this.context.mozImageSmoothingEnabled = false;
|
this.context.mozImageSmoothingEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hover() {
|
||||||
|
// Hide all the layers but the current one
|
||||||
|
for (let i=1; i<layers.length - 2; i++) {
|
||||||
|
if (layers[i] !== this) {
|
||||||
|
layers[i].canvas.style.opacity = 0.3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unhover() {
|
||||||
|
// Show all the layers again
|
||||||
|
for (let i=1; i<layers.length - 2; i++) {
|
||||||
|
if (layers[i] !== this) {
|
||||||
|
layers[i].canvas.style.opacity = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setID(id) {
|
setID(id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
if (this.menuEntry != null) {
|
if (this.menuEntry != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user