Require Ctrl+Mouse Wheel for modifier weight adjustment

The current behavior is just too annoying, and scrolling the page is a much more frequent activity than tweaking the weights.
This commit is contained in:
patriceac 2022-11-27 01:35:47 -08:00
parent 347fa0fda1
commit da41a74efc
2 changed files with 33 additions and 31 deletions

View File

@ -82,7 +82,7 @@
</div> </div>
<div id="editor-inputs-tags-container" class="row"> <div id="editor-inputs-tags-container" class="row">
<label>Image Modifiers: <small>(click an Image Modifier to remove it)</small></label> <label>Image Modifiers: <small>(click an Image Modifier to remove it, Ctrl+Mouse Wheel to adjust an Image Modifier's weight)</small></label>
<div id="editor-inputs-tags-list"></div> <div id="editor-inputs-tags-list"></div>
</div> </div>

View File

@ -18,40 +18,42 @@
let overlays = document.querySelector('#editor-inputs-tags-list').querySelectorAll('.modifier-card-overlay') let overlays = document.querySelector('#editor-inputs-tags-list').querySelectorAll('.modifier-card-overlay')
overlays.forEach (i => { overlays.forEach (i => {
i.onwheel = (e) => { i.onwheel = (e) => {
e.preventDefault() if (e.ctrlKey == true) {
e.preventDefault()
const delta = Math.sign(event.deltaY)
let s = i.parentElement.getElementsByClassName('modifier-card-label')[0].getElementsByTagName("p")[0].innerText const delta = Math.sign(event.deltaY)
if (delta < 0) { let s = i.parentElement.getElementsByClassName('modifier-card-label')[0].getElementsByTagName("p")[0].innerText
// wheel scrolling up if (delta < 0) {
if (s.substring(0, 1) == '[' && s.substring(s.length-1) == ']') { // wheel scrolling up
s = s.substring(1, s.length - 1) if (s.substring(0, 1) == '[' && s.substring(s.length-1) == ']') {
} s = s.substring(1, s.length - 1)
else }
{ else
if (s.substring(0, 10) !== '('.repeat(10) && s.substring(s.length-10) !== ')'.repeat(10)) { {
s = '(' + s + ')' if (s.substring(0, 10) !== '('.repeat(10) && s.substring(s.length-10) !== ')'.repeat(10)) {
s = '(' + s + ')'
}
} }
} }
} else{
else{ // wheel scrolling down
// wheel scrolling down if (s.substring(0, 1) == '(' && s.substring(s.length-1) == ')') {
if (s.substring(0, 1) == '(' && s.substring(s.length-1) == ')') { s = s.substring(1, s.length - 1)
s = s.substring(1, s.length - 1) }
} else
else {
{ if (s.substring(0, 10) !== '['.repeat(10) && s.substring(s.length-10) !== ']'.repeat(10)) {
if (s.substring(0, 10) !== '['.repeat(10) && s.substring(s.length-10) !== ']'.repeat(10)) { s = '[' + s + ']'
s = '[' + s + ']' }
} }
} }
} i.parentElement.getElementsByClassName('modifier-card-label')[0].getElementsByTagName("p")[0].innerText = s
i.parentElement.getElementsByClassName('modifier-card-label')[0].getElementsByTagName("p")[0].innerText = s // update activeTags
// update activeTags for (let it = 0; it < overlays.length; it++) {
for (let it = 0; it < overlays.length; it++) { if (i == overlays[it]) {
if (i == overlays[it]) { activeTags[it].name = s
activeTags[it].name = s break
break }
} }
} }
} }