added lightbox selection markers + tweaks and fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6a00c1e4df
commit
b156ba8e7b
@ -80,22 +80,26 @@ body {
|
|||||||
height: 300px;
|
height: 300px;
|
||||||
width: auto;
|
width: auto;
|
||||||
image-rendering: crisp-edges;
|
image-rendering: crisp-edges;
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* selection marker... */
|
||||||
.gallery .images img.current {
|
.gallery .images img.current {
|
||||||
border: solid 2px red;
|
z-index: 1;
|
||||||
|
box-shadow: 0px 0px 0px 5px rgba(255,0,0,0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************** Image markers ***/
|
/*************************************************** Image markers ***/
|
||||||
|
|
||||||
.gallery .images img+.mark {
|
.gallery .images img+.mark {
|
||||||
|
z-index: 1;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* marker: selected */
|
/* marker: selected */
|
||||||
|
.gallery .lightbox.selected:after,
|
||||||
.gallery .images img+.mark.selected:after {
|
.gallery .images img+.mark.selected:after {
|
||||||
content: "";
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -121,6 +125,7 @@ body {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
|
z-index: 1;
|
||||||
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
|
|||||||
@ -22,11 +22,11 @@
|
|||||||
<pre>
|
<pre>
|
||||||
- <s>Gallery: Adaptable image justification in grid</s>
|
- <s>Gallery: Adaptable image justification in grid</s>
|
||||||
- Can we make this passive??? (i.e. CSS only)
|
- Can we make this passive??? (i.e. CSS only)
|
||||||
- Make more accurate -- align right side to pixel...
|
- <s>Make more accurate -- align right side to pixel...</s>
|
||||||
- <s>Gallery: Spacial navigation (up/down/left/right)</s>
|
- <s>Gallery: Spacial navigation (up/down/left/right)</s>
|
||||||
- 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
|
||||||
- <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>
|
||||||
- <b>Lightbox: show selection marker</b>
|
- <s>Lightbox: show selection marker</s>
|
||||||
- <b>Gallery: constructor (list of urls)</b>
|
- <b>Gallery: constructor (list of urls)</b>
|
||||||
- <b>Gallery: views</b>
|
- <b>Gallery: views</b>
|
||||||
- "make view from selection"
|
- "make view from selection"
|
||||||
|
|||||||
@ -19,8 +19,9 @@
|
|||||||
|
|
||||||
// XXX need to account for scrollbar -- add hysteresis???
|
// XXX need to account for scrollbar -- add hysteresis???
|
||||||
var patchFlexRows =
|
var patchFlexRows =
|
||||||
function(elems){
|
function(elems, prevent_row_expansion=false){
|
||||||
var W = elems[0].parentElement.clientWidth - 2
|
// NOTE: -1 here is to compensate for rounding errors...
|
||||||
|
var W = elems[0].parentElement.clientWidth - 1
|
||||||
var w = 0
|
var w = 0
|
||||||
var h
|
var h
|
||||||
var row = []
|
var row = []
|
||||||
@ -37,21 +38,26 @@ function(elems){
|
|||||||
if(elem.offsetTop == top){
|
if(elem.offsetTop == top){
|
||||||
w += elem.offsetWidth
|
w += elem.offsetWidth
|
||||||
row.push(elem)
|
row.push(elem)
|
||||||
// next row...
|
// row donw + prep for next...
|
||||||
} else {
|
} else {
|
||||||
// NOTE: we are checking which will require a lesser resize
|
// NOTE: we are checking which will require a lesser resize
|
||||||
// the current row or it with the next image...
|
// the current row or it with the next image...
|
||||||
var r1 = W / w
|
var r1 = W / w
|
||||||
var r2 = W / (w + elem.offsetWidth)
|
var r2 = W / (w + elem.offsetWidth)
|
||||||
var expanded_row = 1/r1 < r2
|
var expanded_row =
|
||||||
|
prevent_row_expansion ?
|
||||||
|
false
|
||||||
|
: 1/r1 < r2
|
||||||
if(!expanded_row){
|
if(!expanded_row){
|
||||||
var r = r1
|
var r = r1
|
||||||
} else {
|
} else {
|
||||||
var r = r2
|
var r = r2
|
||||||
row.push(elem) }
|
row.push(elem) }
|
||||||
// patch the row...
|
// patch the row...
|
||||||
|
var nw = 0
|
||||||
for(var e of row){
|
for(var e of row){
|
||||||
e.style.height = Math.floor(h * r) + 'px' }
|
e.style.height = (h * r) + 'px'
|
||||||
|
nw += e.offsetWidth }
|
||||||
// prep for next row...
|
// prep for next row...
|
||||||
if(!expanded_row){
|
if(!expanded_row){
|
||||||
w = elem.offsetWidth
|
w = elem.offsetWidth
|
||||||
@ -135,6 +141,9 @@ var keyboard = {
|
|||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
var Gallery = {
|
var Gallery = {
|
||||||
|
|
||||||
|
allow_row_expansion: true,
|
||||||
|
|
||||||
code: `
|
code: `
|
||||||
<div class="gallery">
|
<div class="gallery">
|
||||||
<!-- gallery: content -->
|
<!-- gallery: content -->
|
||||||
@ -342,6 +351,8 @@ var Gallery = {
|
|||||||
// clear deselected...
|
// clear deselected...
|
||||||
for(var mark of this.dom.querySelectorAll('.images img:not(.selected)+.mark')){
|
for(var mark of this.dom.querySelectorAll('.images img:not(.selected)+.mark')){
|
||||||
mark.remove() }
|
mark.remove() }
|
||||||
|
// update lightbox...
|
||||||
|
this.lightbox.update()
|
||||||
return this },
|
return this },
|
||||||
select: function(){
|
select: function(){
|
||||||
this.current?.classList.add('selected')
|
this.current?.classList.add('selected')
|
||||||
@ -371,7 +382,7 @@ var Gallery = {
|
|||||||
return this },
|
return this },
|
||||||
|
|
||||||
update: function(){
|
update: function(){
|
||||||
patchFlexRows(this.images)
|
patchFlexRows(this.images, !this.allow_row_expansion)
|
||||||
return this },
|
return this },
|
||||||
|
|
||||||
load: function(urls){
|
load: function(urls){
|
||||||
@ -438,13 +449,7 @@ var Lightbox = {
|
|||||||
?? (this.gallery.current
|
?? (this.gallery.current
|
||||||
?? this.gallery.next().current
|
?? this.gallery.next().current
|
||||||
?? {}).src
|
?? {}).src
|
||||||
// set caption...
|
this.update()
|
||||||
this.dom.setAttribute('caption',
|
|
||||||
(this.gallery.current
|
|
||||||
?? this.gallery.next().current
|
|
||||||
?? {})
|
|
||||||
.getAttribute('caption')
|
|
||||||
?? '')
|
|
||||||
this.dom.style.display = 'block'
|
this.dom.style.display = 'block'
|
||||||
return this },
|
return this },
|
||||||
hide: function(){
|
hide: function(){
|
||||||
@ -455,6 +460,20 @@ var Lightbox = {
|
|||||||
this.hide()
|
this.hide()
|
||||||
: this.show() },
|
: this.show() },
|
||||||
|
|
||||||
|
update: function(){
|
||||||
|
// set caption...
|
||||||
|
this.dom.setAttribute('caption',
|
||||||
|
(this.gallery.current
|
||||||
|
?? this.gallery.next().current
|
||||||
|
?? {})
|
||||||
|
.getAttribute('caption')
|
||||||
|
?? '')
|
||||||
|
// set selection...
|
||||||
|
this.gallery.current.classList.contains('selected') ?
|
||||||
|
this.dom.classList.add('selected')
|
||||||
|
: this.dom.classList.remove('selected')
|
||||||
|
return this },
|
||||||
|
|
||||||
prev: function(){
|
prev: function(){
|
||||||
this.gallery.prev().show()
|
this.gallery.prev().show()
|
||||||
return this },
|
return this },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user