added click to select option...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-07-22 00:11:20 +03:00
parent b8a0146d63
commit f869066082

View File

@ -143,6 +143,7 @@ var keyboard = {
var Gallery = { var Gallery = {
allow_row_expansion: true, allow_row_expansion: true,
click_to_select: true,
code: ` code: `
<div class="gallery"> <div class="gallery">
@ -405,8 +406,15 @@ var Gallery = {
.addEventListener('click', function(evt){ .addEventListener('click', function(evt){
var target = evt.target var target = evt.target
if(target.tagName == 'IMG'){ if(target.tagName == 'IMG'){
that.current = target // first click selects, second shows...
that.show() } }) if(that.click_to_select){
target.classList.contains('current') ?
that.show()
: (that.current = target)
// first click selects and shows...
} else {
that.current = target
that.show() } } })
// handle resizing... // handle resizing...
new ResizeObserver( new ResizeObserver(