mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-02 12:20:08 +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...
|
// setup...
|
||||||
$(function(){
|
$(function(){
|
||||||
|
// defaults...
|
||||||
toggleTheme('gray')
|
toggleTheme('gray')
|
||||||
|
toggleImageInfo('on')
|
||||||
|
|
||||||
|
autoHideCursor($('.viewer'))
|
||||||
|
|
||||||
// NOTE: this is global so as to not to add any extra complexity to
|
// NOTE: this is global so as to not to add any extra complexity to
|
||||||
// the internal workings...
|
// the internal workings...
|
||||||
@ -45,10 +48,6 @@ $(function(){
|
|||||||
// XXX for some reason this messes up alignment on initial view...
|
// XXX for some reason this messes up alignment on initial view...
|
||||||
//.dblclick(dblClickHandler)
|
//.dblclick(dblClickHandler)
|
||||||
|
|
||||||
|
|
||||||
autoHideCursor($('.viewer'))
|
|
||||||
|
|
||||||
|
|
||||||
$(window)
|
$(window)
|
||||||
.resize(function() {
|
.resize(function() {
|
||||||
// XXX should this be animated or not?
|
// 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',
|
var toggleInlineImageInfo = createCSSClassToggler('.viewer',
|
||||||
|
|||||||
23
ui/ui.js
23
ui/ui.js
@ -14,11 +14,13 @@ var CURSOR_HIDE_TIMEOUT = 2000
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
// XXX revise...
|
// 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){
|
function autoHideCursor(elem){
|
||||||
elem = $(elem)
|
elem = $(elem)
|
||||||
elem
|
elem
|
||||||
.on('mousemove', function(evt){
|
.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]
|
[evt.clientX, evt.clientY]
|
||||||
: _cursor_pos
|
: _cursor_pos
|
||||||
|
|
||||||
@ -27,19 +29,34 @@ function autoHideCursor(elem){
|
|||||||
|
|
||||||
if(window._cursor_timeout != null){
|
if(window._cursor_timeout != null){
|
||||||
clearTimeout(_cursor_timeout)
|
clearTimeout(_cursor_timeout)
|
||||||
|
_cursor_timeout = null
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.viewer').css('cursor', '')
|
elem.css('cursor', '')
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_cursor_timeout = setTimeout(function(){
|
_cursor_timeout = setTimeout(function(){
|
||||||
if(Math.abs(evt.clientX - _cursor_pos[0]) < CURSOR_SHOW_THRESHOLD
|
if(Math.abs(evt.clientX - _cursor_pos[0]) < CURSOR_SHOW_THRESHOLD
|
||||||
|| Math.abs(evt.clientY - _cursor_pos[1]) < CURSOR_SHOW_THRESHOLD){
|
|| Math.abs(evt.clientY - _cursor_pos[1]) < CURSOR_SHOW_THRESHOLD){
|
||||||
$('.viewer').css('cursor', 'none')
|
elem.css('cursor', 'none')
|
||||||
}
|
}
|
||||||
}, CURSOR_HIDE_TIMEOUT)
|
}, 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
|
return elem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user