Add some scrolling to the Thumbnail bar.

This commit is contained in:
Zixaphir 2013-08-24 22:19:30 -07:00
parent f07a0a1694
commit 209154d905
3 changed files with 42 additions and 7 deletions

View File

@ -6665,11 +6665,14 @@
return cb(); return cb();
}, },
open: function(e) { open: function(e) {
var el, img, name, nodes; var el, img, name, nodes, rect, top;
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
} }
if (!this) {
return;
}
nodes = Gallery.nodes; nodes = Gallery.nodes;
name = nodes.name; name = nodes.name;
if (el = $('.gal-highlight', Gallery.thumbs)) { if (el = $('.gal-highlight', Gallery.thumbs)) {
@ -6685,7 +6688,16 @@
nodes.count.textContent = +this.dataset.id + 1; nodes.count.textContent = +this.dataset.id + 1;
nodes.current = img; nodes.current = img;
nodes.frame.scrollTop = 0; nodes.frame.scrollTop = 0;
return nodes.current.focus(); nodes.current.focus();
rect = this.getBoundingClientRect();
top = rect.top;
if (top > 0) {
top += rect.height - doc.clientHeight;
if (top < 0) {
return;
}
}
return nodes.thumbs.scrollTop += top;
}, },
image: function(e) { image: function(e) {
e.preventDefault(); e.preventDefault();

View File

@ -6650,11 +6650,14 @@
return cb(); return cb();
}, },
open: function(e) { open: function(e) {
var el, img, name, nodes; var el, img, name, nodes, rect, top;
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
} }
if (!this) {
return;
}
nodes = Gallery.nodes; nodes = Gallery.nodes;
name = nodes.name; name = nodes.name;
if (el = $('.gal-highlight', Gallery.thumbs)) { if (el = $('.gal-highlight', Gallery.thumbs)) {
@ -6670,7 +6673,16 @@
nodes.count.textContent = +this.dataset.id + 1; nodes.count.textContent = +this.dataset.id + 1;
nodes.current = img; nodes.current = img;
nodes.frame.scrollTop = 0; nodes.frame.scrollTop = 0;
return nodes.current.focus(); nodes.current.focus();
rect = this.getBoundingClientRect();
top = rect.top;
if (top > 0) {
top += rect.height - doc.clientHeight;
if (top < 0) {
return;
}
}
return nodes.thumbs.scrollTop += top;
}, },
image: function(e) { image: function(e) {
e.preventDefault(); e.preventDefault();

View File

@ -138,6 +138,8 @@ Gallery =
open: (e) -> open: (e) ->
e.preventDefault() if e e.preventDefault() if e
return unless @
{nodes} = Gallery {nodes} = Gallery
{name} = nodes {name} = nodes
@ -155,6 +157,15 @@ Gallery =
nodes.frame.scrollTop = 0 nodes.frame.scrollTop = 0
nodes.current.focus() nodes.current.focus()
# Scroll
rect = @getBoundingClientRect()
{top} = rect
if top > 0
top += rect.height - doc.clientHeight
return if top < 0
nodes.thumbs.scrollTop += top
image: (e) -> image: (e) ->
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()