I am trying to delay mousehouver event in the jQuery below
document.observe('mouseover', (function (event) {
var target = event.findElement('a[rel^=lightbox]') || event.findElement('area[rel^=lightbox]');
if (target) {
event.stop();
this.start(target);
}
}).bind(this));
},
I tried like this
document.observe('mouseover', (function (event), 2000) {
var target = event.findElement('a[rel^=lightbox]') || event.findElement('area[rel^=lightbox]');
if (target) {
event.stop();
this.start(target);
}
}).bind(this));
},
But it didnt work.
Please how do i make this work ?
Thanks
I have also tried this, but hover is not working.
var hoverTimeout;
document.observe('mouseenter', (function(event){
hoverTimeout = setTimeout(function(){
document.observe('mouseover', (function(event){
var target = event.findElement('a[rel^=lightbox]') || event.findElement('area[rel^=lightbox]');
if (target) {
event.stop();
this.start(target);
}
}).bind(this));
},
}, 2000);
});
You'll want to do this (probably with slight modifications, since I didn't test this code) to override the behavior in the Lightbox event handler, this should be placed right after you load the Lightbox script:
<script src="js/lightbox.js" type="text/javascript"></script>
<script type="text/javascript">
Lightbox.prototype.updateImageList = function() {
this.updateImageList = Prototype.emptyFunction;
var hoverTimeout, delayMilliseconds = 2000;
document.observe('mouseover', (function(event){
var target = event.findElement('a[rel^=lightbox]')
|| event.findElement('area[rel^=lightbox]');
if (target) {
hoverTimeout = setTimeout(function(){
event.stop();
this.start(target);
}, delayMilliseconds);
target.one('mouseleave', function(){
clearTimeout(hoverTimeout);
});
}
}).bind(this));
};
</script>
Check out the hoverIntent plugin, I think it's just what you're looking for :). http://cherne.net/brian/resources/jquery.hoverIntent.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.