Fix for pressed property missing with custom controls (Fixes #1062)
This commit is contained in:
parent
95f6fa2731
commit
286d0d1794
29
src/js/controls.js
vendored
29
src/js/controls.js
vendored
@ -275,18 +275,6 @@ const controls = {
|
|||||||
this.elements.buttons[type] = button;
|
this.elements.buttons[type] = button;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle classname when pressed property is set
|
|
||||||
const className = this.config.classNames.controlPressed;
|
|
||||||
Object.defineProperty(button, 'pressed', {
|
|
||||||
enumerable: true,
|
|
||||||
get() {
|
|
||||||
return hasClass(button, className);
|
|
||||||
},
|
|
||||||
set(pressed = false) {
|
|
||||||
toggleClass(button, className, pressed);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1620,6 +1608,23 @@ const controls = {
|
|||||||
controls.findElements.call(this);
|
controls.findElements.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add pressed property to buttons
|
||||||
|
if (!is.empty(this.elements.buttons)) {
|
||||||
|
// Toggle classname when pressed property is set
|
||||||
|
Object.values(this.elements.buttons).forEach(button => {
|
||||||
|
const className = this.config.classNames.controlPressed;
|
||||||
|
Object.defineProperty(button, 'pressed', {
|
||||||
|
enumerable: true,
|
||||||
|
get() {
|
||||||
|
return hasClass(button, className);
|
||||||
|
},
|
||||||
|
set(pressed = false) {
|
||||||
|
toggleClass(button, className, pressed);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Edge sometimes doesn't finish the paint so force a redraw
|
// Edge sometimes doesn't finish the paint so force a redraw
|
||||||
if (window.navigator.userAgent.includes('Edge')) {
|
if (window.navigator.userAgent.includes('Edge')) {
|
||||||
repaint(target);
|
repaint(target);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user