discard other keypresses
This commit is contained in:
54
README.md
54
README.md
@@ -1,26 +1,28 @@
|
|||||||
# Mirva
|
# Mirva
|
||||||
|
|
||||||
A tool to create a web gallery from a single folder of images.
|
A tool to create a web gallery from a single folder of images.
|
||||||
Also .mp4 files are included in the gallery
|
Also .mp4 files are included in the gallery
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Usage requires ImageMagick binaries! Make sure you have `convert` in PATH.
|
Usage requires ImageMagick binaries! Make sure you have `convert` in PATH.
|
||||||
|
|
||||||
Use pip or similar to install from source.
|
Use pip or similar to install from source.
|
||||||
|
|
||||||
ex.
|
ex.
|
||||||
|
|
||||||
`pip3 install --user --upgrade https://bitbucket.org/MoonQ/mirva/get/master.zip`
|
`pip3 install --user --upgrade https://bitbucket.org/MoonQ/mirva/get/master.zip`
|
||||||
|
|
||||||
or `pipx install https://bitbucket.org/MoonQ/mirva/get/master.zip`
|
or `pipx install https://bitbucket.org/MoonQ/mirva/get/master.zip`
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use the command line tool `mirva` to render web sites.
|
Use the command line tool `mirva` to render web sites.
|
||||||
|
|
||||||
|
note: Arrow keys left/right on web page move between images.
|
||||||
## Acknowledgements
|
|
||||||
|
|
||||||
Thank you Mirva for being a lustrous source of inspiration - May you stay
|
## Acknowledgements
|
||||||
full of joy and love!
|
|
||||||
|
Thank you Mirva for being a lustrous source of inspiration - May you stay
|
||||||
|
full of joy and love!
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
let current=0;
|
let current=-1;
|
||||||
function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}
|
function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}
|
||||||
r(function(){
|
r(function(){
|
||||||
create_nav();
|
create_nav();
|
||||||
document.onkeydown = keyboard_entry;
|
document.onkeydown = keyboard_entry;
|
||||||
|
document.onwheel = scroll_event;
|
||||||
|
|
||||||
});
|
});
|
||||||
function create_nav() {
|
function create_nav() {
|
||||||
@@ -35,25 +36,45 @@ function create_button(direction, to, next) {
|
|||||||
container.appendChild(button);
|
container.appendChild(button);
|
||||||
return container
|
return container
|
||||||
}
|
}
|
||||||
|
function is_visible(el) {
|
||||||
|
let rect = el.getBoundingClientRect();
|
||||||
|
return rect.top < window.innerHeight && rect.bottom >= 0;
|
||||||
|
}
|
||||||
|
function scroll_event(ev) {
|
||||||
|
let navis = document.getElementsByClassName("navigation");
|
||||||
|
for (let i = 0; i<navis.length; i++) {
|
||||||
|
if (is_visible(navis[i])) {
|
||||||
|
current = i -1;
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
function keyboard_entry(ev) {
|
function keyboard_entry(ev) {
|
||||||
var kC = ev.keyCode;
|
let kC = ev.keyCode;
|
||||||
var k = String.fromCharCode(ev.keyCode);
|
let ctrlDown = ev.ctrlKey || ev.metaKey;
|
||||||
var ctrlDown = ev.ctrlKey || ev.metaKey;
|
|
||||||
if (ctrlDown) {
|
if (ctrlDown) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ([32,33,34,35,36,37,38,39,40].indexOf(kC) == -1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
let navis = document.getElementsByClassName("navigation");
|
let navis = document.getElementsByClassName("navigation");
|
||||||
if (kC == '39') { // right
|
if (kC == '36') { // home
|
||||||
|
current = -1;
|
||||||
|
return
|
||||||
|
}
|
||||||
|
else if (kC == '35') { // end
|
||||||
|
current = navis.length;
|
||||||
|
return
|
||||||
|
}
|
||||||
|
else if (kC == '39') { // right
|
||||||
current += 1;
|
current += 1;
|
||||||
}
|
}
|
||||||
if (kC == '37') { // left
|
else if (kC == '37') { // left
|
||||||
current -= 1;
|
current -= 1;
|
||||||
}
|
} else {
|
||||||
if (kC == '36') { // home
|
setTimeout(scroll_event, 100);
|
||||||
current = 0;
|
return
|
||||||
}
|
|
||||||
if (kC == '35') { // end
|
|
||||||
current = navis.length-1;
|
|
||||||
}
|
}
|
||||||
current = Math.max(0, current);
|
current = Math.max(0, current);
|
||||||
current = Math.min(navis.length-1, current);
|
current = Math.min(navis.length-1, current);
|
||||||
|
|||||||
Reference in New Issue
Block a user