several options and configs added + cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
673912b219
commit
e0de8a9a13
@ -9,8 +9,16 @@
|
|||||||
|
|
||||||
:root {
|
:root {
|
||||||
/* dimensions */
|
/* dimensions */
|
||||||
--gallery-scrollbar-width: 0.5em;
|
--gallery-current-border-size: 0.7em;
|
||||||
|
--gallery-padding: 3em;
|
||||||
|
--gallery-padding-horizontal: var(--gallery-padding);
|
||||||
|
--gallery-padding-vertical: var(--gallery-current-border-size);
|
||||||
|
--gallery-padding-top: var(--gallery-padding-vertical);
|
||||||
|
--gallery-padding-bottom: var(--gallery-padding-vertical);
|
||||||
|
--gallery-padding-left: var(--gallery-padding-horizontal);
|
||||||
|
--gallery-padding-right: var(--gallery-padding-horizontal);
|
||||||
--gallery-image-scroll-margin: 1em;
|
--gallery-image-scroll-margin: 1em;
|
||||||
|
--gallery-scrollbar-width: 0.5em;
|
||||||
|
|
||||||
--lightbox-frame-size: 5vmin;
|
--lightbox-frame-size: 5vmin;
|
||||||
--lightbox-image-margin-top: 0.75;
|
--lightbox-image-margin-top: 0.75;
|
||||||
@ -64,8 +72,12 @@ body {
|
|||||||
|
|
||||||
/* XXX need to account for scrollbar popping in and out */
|
/* XXX need to account for scrollbar popping in and out */
|
||||||
.gallery {
|
.gallery {
|
||||||
margin-left: var(--gallery-scrollbar-width);
|
padding-top: var(--gallery-padding-top);
|
||||||
margin-right: 0;
|
padding-bottom: var(--gallery-padding-bottom);
|
||||||
|
padding-left: calc(
|
||||||
|
var(--gallery-scrollbar-width)
|
||||||
|
+ var(--gallery-padding-left) );
|
||||||
|
padding-right: var(--gallery-padding-right);
|
||||||
|
|
||||||
color: var(--gallery-text-color);
|
color: var(--gallery-text-color);
|
||||||
background: var(--gallery-background-color);
|
background: var(--gallery-background-color);
|
||||||
@ -90,8 +102,8 @@ body {
|
|||||||
.gallery .images img.current {
|
.gallery .images img.current {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
box-shadow:
|
box-shadow:
|
||||||
0px 0px 0px 0.5em rgba(255,255,255,1),
|
0px 0px 0px var(--gallery-current-border-size) rgba(255,255,255,1),
|
||||||
0.3em 0.3em 3em 0em rgba(0,0,0,0.8);
|
0.4em 0.4em 3em 0em rgba(0,0,0,0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
- <b>option: .loop_images (in porgress)</b>
|
- <b>option: .loop_images (in porgress)</b>
|
||||||
- Up/Down: might be a good idea to err slightly to the left
|
- Up/Down: might be a good idea to err slightly to the left
|
||||||
- Gallery: PageUp/PageDown, home/end + allow page navigation
|
- Gallery: PageUp/PageDown, home/end + allow page navigation
|
||||||
- Gallery: focus nearest visible...
|
- <b>Gallery: focus visible (if no current)...</b>
|
||||||
- <s>Gallery/Lightbox: Selection of images (space / ctrl-a / ctrl-d / ctrl-i)</s>
|
- <s>Gallery/Lightbox: Selection of images (space / ctrl-a / ctrl-d / ctrl-i)</s>
|
||||||
- <s>Lightbox: show selection marker</s>
|
- <s>Lightbox: show selection marker</s>
|
||||||
- <b>Gallery: constructor (list of urls)</b>
|
- <b>Gallery: constructor (list of urls)</b>
|
||||||
|
|||||||
@ -115,8 +115,13 @@ var keyboard = {
|
|||||||
Enter: function(){
|
Enter: function(){
|
||||||
gallery.lightbox.toggle() },
|
gallery.lightbox.toggle() },
|
||||||
Escape: function(){
|
Escape: function(){
|
||||||
gallery.lightbox.shown
|
gallery.lightbox.shown ?
|
||||||
&& gallery.lightbox.hide() },
|
gallery.lightbox.hide()
|
||||||
|
// XXX should we remember which image was current and select
|
||||||
|
// it again when needed???
|
||||||
|
: gallery.deselect_current ?
|
||||||
|
(gallery.current = null)
|
||||||
|
: null },
|
||||||
// selection...
|
// selection...
|
||||||
' ': function(evt){
|
' ': function(evt){
|
||||||
gallery.current
|
gallery.current
|
||||||
@ -145,6 +150,7 @@ var Gallery = {
|
|||||||
|
|
||||||
// options...
|
// options...
|
||||||
//
|
//
|
||||||
|
deselect_current: true,
|
||||||
loop_images: true,
|
loop_images: true,
|
||||||
allow_row_expansion: true,
|
allow_row_expansion: true,
|
||||||
click_to_select: true,
|
click_to_select: true,
|
||||||
@ -178,6 +184,11 @@ var Gallery = {
|
|||||||
get current(){
|
get current(){
|
||||||
return this.dom.querySelector('.images img.current') },
|
return this.dom.querySelector('.images img.current') },
|
||||||
set current(img){
|
set current(img){
|
||||||
|
// unset...
|
||||||
|
if(img == null){
|
||||||
|
this.current?.classList.remove('current')
|
||||||
|
return }
|
||||||
|
// set...
|
||||||
for(var i of this.dom.querySelectorAll('.images img.current')){
|
for(var i of this.dom.querySelectorAll('.images img.current')){
|
||||||
i.classList.remove('current') }
|
i.classList.remove('current') }
|
||||||
img.classList.add('current')
|
img.classList.add('current')
|
||||||
@ -298,6 +309,7 @@ var Gallery = {
|
|||||||
return target },
|
return target },
|
||||||
|
|
||||||
// XXX cache image list???
|
// XXX cache image list???
|
||||||
|
// XXX add .loop_images support...
|
||||||
prev: function(){
|
prev: function(){
|
||||||
var images = this.images
|
var images = this.images
|
||||||
var i = this.current == null ?
|
var i = this.current == null ?
|
||||||
@ -325,9 +337,7 @@ var Gallery = {
|
|||||||
var row = this.getRow(cur)
|
var row = this.getRow(cur)
|
||||||
var i = row.indexOf(cur) - 1
|
var i = row.indexOf(cur) - 1
|
||||||
this.current = row[i < 0 ?
|
this.current = row[i < 0 ?
|
||||||
(this.loop_images ?
|
row.length-1
|
||||||
row.length-1
|
|
||||||
: 0)
|
|
||||||
: i]
|
: i]
|
||||||
return this },
|
return this },
|
||||||
right: function(){
|
right: function(){
|
||||||
@ -335,9 +345,7 @@ var Gallery = {
|
|||||||
var row = this.getRow(cur)
|
var row = this.getRow(cur)
|
||||||
var i = row.indexOf(cur) + 1
|
var i = row.indexOf(cur) + 1
|
||||||
this.current = row[i >= row.length ?
|
this.current = row[i >= row.length ?
|
||||||
(this.loop_images ?
|
0
|
||||||
0
|
|
||||||
: row.length-1)
|
|
||||||
: i]
|
: i]
|
||||||
return this },
|
return this },
|
||||||
up: function(){
|
up: function(){
|
||||||
@ -426,6 +434,7 @@ var Gallery = {
|
|||||||
|
|
||||||
this.dom.querySelector('.images')
|
this.dom.querySelector('.images')
|
||||||
.addEventListener('click', function(evt){
|
.addEventListener('click', function(evt){
|
||||||
|
evt.stopPropagation()
|
||||||
var target = evt.target
|
var target = evt.target
|
||||||
if(target.tagName == 'IMG'){
|
if(target.tagName == 'IMG'){
|
||||||
// shift+click: toggle selections...
|
// shift+click: toggle selections...
|
||||||
@ -439,7 +448,13 @@ var Gallery = {
|
|||||||
// first click selects and shows...
|
// first click selects and shows...
|
||||||
} else {
|
} else {
|
||||||
that.current = target
|
that.current = target
|
||||||
that.show() } } })
|
that.show() }
|
||||||
|
} else if(that.deselect_current){
|
||||||
|
that.current = null } })
|
||||||
|
this.dom
|
||||||
|
.addEventListener('click', function(evt){
|
||||||
|
that.deselect_current
|
||||||
|
&& (that.current = null) })
|
||||||
|
|
||||||
// handle resizing...
|
// handle resizing...
|
||||||
new ResizeObserver(
|
new ResizeObserver(
|
||||||
@ -550,6 +565,7 @@ var Lightbox = {
|
|||||||
var deadzone = this.navigation_deadzone ?? 100
|
var deadzone = this.navigation_deadzone ?? 100
|
||||||
this.dom
|
this.dom
|
||||||
.addEventListener('click', function(evt){
|
.addEventListener('click', function(evt){
|
||||||
|
evt.stopPropagation()
|
||||||
// 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
|
evt.clientX < that.dom.offsetWidth / 2 - deadzone/2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user