mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-31 19:30:07 +00:00
some more refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
076bd43a96
commit
d7714eb0b2
@ -35,8 +35,11 @@
|
||||
|
||||
// setup...
|
||||
$(function(){
|
||||
|
||||
// defaults...
|
||||
toggleTheme('gray')
|
||||
toggleImageInfo('on')
|
||||
|
||||
autoHideCursor($('.viewer'))
|
||||
|
||||
// NOTE: this is global so as to not to add any extra complexity to
|
||||
// the internal workings...
|
||||
@ -45,10 +48,6 @@ $(function(){
|
||||
// XXX for some reason this messes up alignment on initial view...
|
||||
//.dblclick(dblClickHandler)
|
||||
|
||||
|
||||
autoHideCursor($('.viewer'))
|
||||
|
||||
|
||||
$(window)
|
||||
.resize(function() {
|
||||
// XXX should this be animated or not?
|
||||
|
||||
@ -66,7 +66,13 @@ var toggleTheme = createCSSClassToggler('.viewer',
|
||||
})
|
||||
|
||||
|
||||
var toggleImageInfo = createCSSClassToggler('.viewer', '.image-info-visible')
|
||||
var toggleImageInfo = createCSSClassToggler('.viewer',
|
||||
'.image-info-visible',
|
||||
function(action){
|
||||
if(toggleSingleImageMode('?') == 'off'){
|
||||
SETTINGS['image-info-ribbon-mode'] = action
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
var toggleInlineImageInfo = createCSSClassToggler('.viewer',
|
||||
|
||||
23
ui/ui.js
23
ui/ui.js
@ -14,11 +14,13 @@ var CURSOR_HIDE_TIMEOUT = 2000
|
||||
/*********************************************************************/
|
||||
|
||||
// XXX revise...
|
||||
// NOTE: to catch the click event correctly while the cursor is hidden
|
||||
// this must be the first to get the event...
|
||||
function autoHideCursor(elem){
|
||||
elem = $(elem)
|
||||
elem
|
||||
.on('mousemove', function(evt){
|
||||
_cursor_pos = window._cursor_pos == null || $('.viewer').css('cursor') == 'auto' ?
|
||||
_cursor_pos = window._cursor_pos == null || elem.css('cursor') == 'auto' ?
|
||||
[evt.clientX, evt.clientY]
|
||||
: _cursor_pos
|
||||
|
||||
@ -27,19 +29,34 @@ function autoHideCursor(elem){
|
||||
|
||||
if(window._cursor_timeout != null){
|
||||
clearTimeout(_cursor_timeout)
|
||||
_cursor_timeout = null
|
||||
}
|
||||
|
||||
$('.viewer').css('cursor', '')
|
||||
elem.css('cursor', '')
|
||||
|
||||
} else {
|
||||
_cursor_timeout = setTimeout(function(){
|
||||
if(Math.abs(evt.clientX - _cursor_pos[0]) < CURSOR_SHOW_THRESHOLD
|
||||
|| Math.abs(evt.clientY - _cursor_pos[1]) < CURSOR_SHOW_THRESHOLD){
|
||||
$('.viewer').css('cursor', 'none')
|
||||
elem.css('cursor', 'none')
|
||||
}
|
||||
}, CURSOR_HIDE_TIMEOUT)
|
||||
}
|
||||
})
|
||||
.click(function(evt){
|
||||
if(elem.css('cursor') == 'none'){
|
||||
//event.stopImmediatePropagation()
|
||||
//event.preventDefault()
|
||||
|
||||
if(window._cursor_timeout != null){
|
||||
clearTimeout(_cursor_timeout)
|
||||
_cursor_timeout = null
|
||||
}
|
||||
|
||||
elem.css('cursor', '')
|
||||
//return false
|
||||
}
|
||||
})
|
||||
return elem
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user