Add image hover event listeners only when needed.

This commit is contained in:
Nicolas Stepien 2012-02-18 19:15:38 +01:00
parent b1f257fbd9
commit 24440ad0ad
2 changed files with 14 additions and 5 deletions

View File

@ -3313,16 +3313,21 @@
node: function(root) {
var thumb;
if (!(thumb = $('img[md5]', root))) return;
$.on(thumb, 'mouseover', imgHover.mouseover);
$.on(thumb, 'mousemove', ui.hover);
return $.on(thumb, 'mouseout', ui.hoverend);
return $.on(thumb, 'mouseover', imgHover.mouseover);
},
mouseover: function() {
ui.el = $.el('img', {
id: 'ihover',
src: this.parentNode.href
});
$.on(this, 'mousemove', ui.hover);
$.on(this, 'mouseout', imgHover.mouseout);
return $.add(d.body, ui.el);
},
mouseout: function() {
ui.hoverend();
$.off(this, 'mousemove', ui.hover);
return $.off(this, 'mouseout', imgHover.mouseout);
}
};

View File

@ -2612,13 +2612,17 @@ imgHover =
node: (root) ->
return unless thumb = $ 'img[md5]', root
$.on thumb, 'mouseover', imgHover.mouseover
$.on thumb, 'mousemove', ui.hover
$.on thumb, 'mouseout', ui.hoverend
mouseover: ->
ui.el = $.el 'img'
id: 'ihover'
src: @parentNode.href
$.on @, 'mousemove', ui.hover
$.on @, 'mouseout', imgHover.mouseout
$.add d.body, ui.el
mouseout: ->
ui.hoverend()
$.off @, 'mousemove', ui.hover
$.off @, 'mouseout', imgHover.mouseout
imgGif =
init: ->