mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-01 11:50:07 +00:00
updated the way the cursor hiding stores data -- now element specific and reusable for multiple elements...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
90174366f7
commit
6f05e8a633
11
ui/files.js
11
ui/files.js
@ -171,6 +171,7 @@ function loadLatestFile(path, dfl, pattern, diff_pattern){
|
|||||||
//
|
//
|
||||||
// NOTE: this depends on listDir(...)
|
// NOTE: this depends on listDir(...)
|
||||||
// NOTE: this assumes that images contain ALL the images...
|
// NOTE: this assumes that images contain ALL the images...
|
||||||
|
// NOTE: this assumes that all file names are unique...
|
||||||
function ribbonsFromFavDirs(path, images, cmp){
|
function ribbonsFromFavDirs(path, images, cmp){
|
||||||
path = path == null ? getBaseURL() : path
|
path = path == null ? getBaseURL() : path
|
||||||
images = images == null ? IMAGES : images
|
images = images == null ? IMAGES : images
|
||||||
@ -198,9 +199,11 @@ function ribbonsFromFavDirs(path, images, cmp){
|
|||||||
// collect the images...
|
// collect the images...
|
||||||
$.each(files, function(i, e){
|
$.each(files, function(i, e){
|
||||||
var _gid = index[e]
|
var _gid = index[e]
|
||||||
// filter out non-image files...
|
// skip files not in index...
|
||||||
if(/.*\.(jpg|jpeg)$/i.test(e)){
|
// NOTE: we do not need to filter the files by name as we
|
||||||
ribbon.push(_gid)
|
// trust the index...
|
||||||
|
if(_gid == null){
|
||||||
|
return
|
||||||
}
|
}
|
||||||
// remove the found item from each of the below ribbons...
|
// remove the found item from each of the below ribbons...
|
||||||
$.each(ribbons, function(i ,e){
|
$.each(ribbons, function(i ,e){
|
||||||
@ -208,6 +211,8 @@ function ribbonsFromFavDirs(path, images, cmp){
|
|||||||
e.splice(e.indexOf(_gid), 1)
|
e.splice(e.indexOf(_gid), 1)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ribbon.push(_gid)
|
||||||
})
|
})
|
||||||
ribbons.push(ribbon)
|
ribbons.push(ribbon)
|
||||||
}
|
}
|
||||||
|
|||||||
40
ui/ui.js
40
ui/ui.js
@ -20,25 +20,27 @@ var STATUS_QUEUE_TIME = 200
|
|||||||
// XXX revise...
|
// XXX revise...
|
||||||
// NOTE: to catch the click event correctly while the cursor is hidden
|
// NOTE: to catch the click event correctly while the cursor is hidden
|
||||||
// this must be the first to get the event...
|
// this must be the first to get the event...
|
||||||
|
// NOTE: this uses element.data to store the timer and cursor position...
|
||||||
function autoHideCursor(elem){
|
function autoHideCursor(elem){
|
||||||
elem = $(elem)
|
elem = $(elem)
|
||||||
|
var data = elem.data()
|
||||||
elem
|
elem
|
||||||
.on('mousemove', function(evt){
|
.on('mousemove', function(evt){
|
||||||
var cursor = elem.css('cursor')
|
var cursor = elem.css('cursor')
|
||||||
|
|
||||||
_cursor_pos = window._cursor_pos == null || cursor != 'none' ?
|
data._cursor_pos = data._cursor_pos == null || cursor != 'none' ?
|
||||||
[evt.clientX, evt.clientY]
|
[evt.clientX, evt.clientY]
|
||||||
: _cursor_pos
|
: data._cursor_pos
|
||||||
|
|
||||||
// cursor visible -- extend visibility...
|
// cursor visible -- extend visibility...
|
||||||
if(cursor != 'none'){
|
if(cursor != 'none'){
|
||||||
|
|
||||||
if(window._cursor_timeout != null){
|
if(data._cursor_timeout != null){
|
||||||
clearTimeout(_cursor_timeout)
|
clearTimeout(data._cursor_timeout)
|
||||||
}
|
}
|
||||||
_cursor_timeout = setTimeout(function(){
|
data._cursor_timeout = setTimeout(function(){
|
||||||
if(Math.abs(evt.clientX - _cursor_pos[0]) < CURSOR_SHOW_THRESHOLD
|
if(Math.abs(evt.clientX - data._cursor_pos[0]) < CURSOR_SHOW_THRESHOLD
|
||||||
|| Math.abs(evt.clientY - _cursor_pos[1]) < CURSOR_SHOW_THRESHOLD){
|
|| Math.abs(evt.clientY - data._cursor_pos[1]) < CURSOR_SHOW_THRESHOLD){
|
||||||
|
|
||||||
elem.css('cursor', 'none')
|
elem.css('cursor', 'none')
|
||||||
}
|
}
|
||||||
@ -46,8 +48,8 @@ function autoHideCursor(elem){
|
|||||||
|
|
||||||
|
|
||||||
// cursor hidden -- if outside the threshold, show...
|
// cursor hidden -- if outside the threshold, show...
|
||||||
} else if(Math.abs(evt.clientX - _cursor_pos[0]) > CURSOR_SHOW_THRESHOLD
|
} else if(Math.abs(evt.clientX - data._cursor_pos[0]) > CURSOR_SHOW_THRESHOLD
|
||||||
|| Math.abs(evt.clientY - _cursor_pos[1]) > CURSOR_SHOW_THRESHOLD){
|
|| Math.abs(evt.clientY - data._cursor_pos[1]) > CURSOR_SHOW_THRESHOLD){
|
||||||
|
|
||||||
elem.css('cursor', '')
|
elem.css('cursor', '')
|
||||||
}
|
}
|
||||||
@ -57,9 +59,9 @@ function autoHideCursor(elem){
|
|||||||
//event.stopImmediatePropagation()
|
//event.stopImmediatePropagation()
|
||||||
//event.preventDefault()
|
//event.preventDefault()
|
||||||
|
|
||||||
if(window._cursor_timeout != null){
|
if(data._cursor_timeout != null){
|
||||||
clearTimeout(_cursor_timeout)
|
clearTimeout(data._cursor_timeout)
|
||||||
_cursor_timeout = null
|
data._cursor_timeout = null
|
||||||
}
|
}
|
||||||
|
|
||||||
elem.css('cursor', '')
|
elem.css('cursor', '')
|
||||||
@ -70,6 +72,20 @@ function autoHideCursor(elem){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
// XXX does not work...
|
||||||
|
// ...does not show the cursor without moving it...
|
||||||
|
function showCursor(elem){
|
||||||
|
elem = $(elem)
|
||||||
|
var data = elem.data()
|
||||||
|
if(data._cursor_timeout != null){
|
||||||
|
clearTimeout(data._cursor_timeout)
|
||||||
|
}
|
||||||
|
elem.css('cursor', '')
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
function flashIndicator(direction){
|
function flashIndicator(direction){
|
||||||
var cls = {
|
var cls = {
|
||||||
// shift up/down...
|
// shift up/down...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user