added double click handling...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
45130ab8d2
commit
5e4f69c88a
@ -233,9 +233,10 @@ body {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 1em;
|
top: 1em;
|
||||||
|
margin-left: calc(var(--gallery-padding-horizontal) * -1);
|
||||||
padding: var(--padding);
|
padding: var(--padding);
|
||||||
|
|
||||||
z-index: calc(var(--base-layer) + 1);
|
z-index: calc(var(--base-layer) + 2);
|
||||||
|
|
||||||
border: solid 1px var(--gallery-secondary-color);
|
border: solid 1px var(--gallery-secondary-color);
|
||||||
background: var(--gallery-background-color);
|
background: var(--gallery-background-color);
|
||||||
|
|||||||
@ -87,8 +87,8 @@ For more info see: <a href="./README.md">README.md</a>
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button onclick="gallery.toggleQueueRemoval()" title="queue removal (del)">◧</button>
|
<button onclick="gallery.toggleQueueRemoval()" title="queue removal (del)">◧</button>
|
||||||
<button onclick="gallery.queueRemoval('marked')" title="queue marked removal">◼⏺</button>
|
<!--button onclick="gallery.queueRemoval('marked')" title="queue marked removal">◼⏺</button-->
|
||||||
<button onclick="gallery.unqueueRemoval('marked')" title="unqueue marked removal">◻⏺</button>
|
<!--button onclick="gallery.unqueueRemoval('marked')" title="unqueue marked removal">◻⏺</button-->
|
||||||
<button onclick="gallery.toggleQueueRemoval('marked')" title="toggle marked removal">◧⏺</button>
|
<button onclick="gallery.toggleQueueRemoval('marked')" title="toggle marked removal">◧⏺</button>
|
||||||
<button onclick="gallery.removeQueued()" title="remove queued (shift-del)">☒</button>
|
<button onclick="gallery.removeQueued()" title="remove queued (shift-del)">☒</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1078,9 +1078,18 @@ var Overlay = {
|
|||||||
&& this.cache_count != 0
|
&& this.cache_count != 0
|
||||||
&& this.cache() },
|
&& this.cache() },
|
||||||
|
|
||||||
|
__clicks_canceled: false,
|
||||||
|
__clicks_canceled_timeout: 500,
|
||||||
|
|
||||||
get shown(){
|
get shown(){
|
||||||
return this.gallery.dom.classList.contains(this.cls) },
|
return this.gallery.dom.classList.contains(this.cls) },
|
||||||
show: function(){
|
show: function(){
|
||||||
|
var that = this
|
||||||
|
this.__clicks_canceled = true
|
||||||
|
setTimeout(
|
||||||
|
function(){
|
||||||
|
that.__clicks_canceled = false },
|
||||||
|
this.__clicks_canceled_timeout ?? 200)
|
||||||
this.update()
|
this.update()
|
||||||
this.gallery.dom.classList.add(this.cls)
|
this.gallery.dom.classList.add(this.cls)
|
||||||
return this },
|
return this },
|
||||||
@ -1130,24 +1139,34 @@ var Overlay = {
|
|||||||
this.dom.querySelector('.close')
|
this.dom.querySelector('.close')
|
||||||
?.addEventListener('click', function(evt){
|
?.addEventListener('click', function(evt){
|
||||||
evt.stopPropagation()
|
evt.stopPropagation()
|
||||||
|
if(that.__clicks_canceled){
|
||||||
|
return }
|
||||||
that.hide() })
|
that.hide() })
|
||||||
this.dom.querySelector('.fullscreen')
|
this.dom.querySelector('.fullscreen')
|
||||||
?.addEventListener('click', function(evt){
|
?.addEventListener('click', function(evt){
|
||||||
evt.stopPropagation()
|
evt.stopPropagation()
|
||||||
|
if(that.__clicks_canceled){
|
||||||
|
return }
|
||||||
document.fullscreenElement ?
|
document.fullscreenElement ?
|
||||||
document.exitFullscreen()
|
document.exitFullscreen()
|
||||||
: that.dom.requestFullscreen() })
|
: that.dom.requestFullscreen() })
|
||||||
this.dom.querySelector('.info')
|
this.dom.querySelector('.info')
|
||||||
?.addEventListener('click', function(evt){
|
?.addEventListener('click', function(evt){
|
||||||
evt.stopPropagation()
|
evt.stopPropagation()
|
||||||
|
if(that.__clicks_canceled){
|
||||||
|
return }
|
||||||
that.gallery.showDetails() })
|
that.gallery.showDetails() })
|
||||||
this.dom.querySelector('.prev')
|
this.dom.querySelector('.prev')
|
||||||
?.addEventListener('click', function(evt){
|
?.addEventListener('click', function(evt){
|
||||||
evt.stopPropagation()
|
evt.stopPropagation()
|
||||||
|
if(that.__clicks_canceled){
|
||||||
|
return }
|
||||||
that.gallery.prev() })
|
that.gallery.prev() })
|
||||||
this.dom.querySelector('.next')
|
this.dom.querySelector('.next')
|
||||||
?.addEventListener('click', function(evt){
|
?.addEventListener('click', function(evt){
|
||||||
evt.stopPropagation()
|
evt.stopPropagation()
|
||||||
|
if(that.__clicks_canceled){
|
||||||
|
return }
|
||||||
that.gallery.next() })
|
that.gallery.next() })
|
||||||
// stop body from scrolling...
|
// stop body from scrolling...
|
||||||
var stop = function(evt){
|
var stop = function(evt){
|
||||||
@ -1179,7 +1198,7 @@ var Lightbox = {
|
|||||||
|
|
||||||
caption_format: '${INDEX} ${CAPTION}',
|
caption_format: '${INDEX} ${CAPTION}',
|
||||||
|
|
||||||
navigation_deadzone: 100,
|
navigation_deadzone: 0.3,
|
||||||
caption_hysteresis: 10,
|
caption_hysteresis: 10,
|
||||||
cache_count: 1,
|
cache_count: 1,
|
||||||
|
|
||||||
@ -1212,25 +1231,39 @@ var Lightbox = {
|
|||||||
Overlay.setup.call(this, ...arguments)
|
Overlay.setup.call(this, ...arguments)
|
||||||
|
|
||||||
// click zones...
|
// click zones...
|
||||||
var deadzone = this.navigation_deadzone ?? 100
|
var dblclick_canceled = false
|
||||||
|
var deadzone = this.navigation_deadzone ?? 0.3
|
||||||
this.dom
|
this.dom
|
||||||
.addEventListener('click', function(evt){
|
.addEventListener('click', function(evt){
|
||||||
evt.stopPropagation()
|
evt.stopPropagation()
|
||||||
|
if(that.__clicks_canceled){
|
||||||
|
return }
|
||||||
|
var d = that.dom.offsetWidth * deadzone
|
||||||
// click left/right side of view...
|
// click left/right side of view...
|
||||||
// NOTE: this is vewport-relative...
|
// NOTE: this is vewport-relative...
|
||||||
evt.clientX < that.dom.offsetWidth / 2 - deadzone/2
|
dblclick_canceled = false
|
||||||
|
evt.clientX < that.dom.offsetWidth / 2 - d/2
|
||||||
&& that.gallery.prev()
|
&& that.gallery.prev()
|
||||||
evt.clientX > that.dom.offsetWidth / 2 + deadzone/2
|
&& (dblclick_canceled = true)
|
||||||
&& that.gallery.next() })
|
evt.clientX > that.dom.offsetWidth / 2 + d/2
|
||||||
|
&& that.gallery.next()
|
||||||
|
&& (dblclick_canceled = true) })
|
||||||
|
this.dom
|
||||||
|
.addEventListener('dblclick', function(evt){
|
||||||
|
evt.stopPropagation()
|
||||||
|
dblclick_canceled
|
||||||
|
|| that.__clicks_canceled
|
||||||
|
|| that.hide() })
|
||||||
// hover zones...
|
// hover zones...
|
||||||
var hysteresis = this.caption_hysteresis ?? 10
|
var hysteresis = this.caption_hysteresis ?? 10
|
||||||
this.dom
|
this.dom
|
||||||
.addEventListener('mousemove', function(evt){
|
.addEventListener('mousemove', function(evt){
|
||||||
|
var d = that.dom.offsetWidth * deadzone
|
||||||
// indicate action...
|
// indicate action...
|
||||||
if(evt.clientX < that.dom.offsetWidth / 2 - deadzone/2){
|
if(evt.clientX < that.dom.offsetWidth / 2 - d/2){
|
||||||
that.dom.classList.contains('clickable')
|
that.dom.classList.contains('clickable')
|
||||||
|| that.dom.classList.add('clickable')
|
|| that.dom.classList.add('clickable')
|
||||||
} else if( evt.clientX > that.dom.offsetWidth / 2 + deadzone/2){
|
} else if( evt.clientX > that.dom.offsetWidth / 2 + d/2){
|
||||||
that.dom.classList.contains('clickable')
|
that.dom.classList.contains('clickable')
|
||||||
|| that.dom.classList.add('clickable')
|
|| that.dom.classList.add('clickable')
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user