onhover Emulation

E

exiquio

So a client requires a useless column on the page that contains
employee profile blocks with little images in them. The div tag
containing the content has an overflow of hidden. It contains more
profile blocks that can be seen. The task is to have the thing scroll
through the profiles when a user hovers the edge. I have it scrolling
one block at a time 'onclick'. My question is this: Is there a simple,
efficient way to capture a continuous mouse hover? I guess I could
keep checking the mouse position, but that seems too inefficient to be
the best way.

Thanks.
 
J

Joost Diepenmaat

exiquio said:
My question is this: Is there a simple, efficient way to capture a
continuous mouse hover? I guess I could keep checking the mouse
position, but that seems too inefficient to be the best way.

You can't "keep checking the mouse position". Just use mousemove events.
 
J

Joost Diepenmaat

Joost Diepenmaat said:
You can't "keep checking the mouse position". Just use mousemove events.

Or mouseout / mouseover events, ofcourse. Those will be more efficient,
for some measure of efficient.
 
E

exiquio

Or mouseout / mouseover events, ofcourse. Those will be more efficient,
for some measure of efficient.

I should have been more clear. I need it to continue even if the mouse
isn't moving; as long the mouse is in the area of the trigger. Thanks
for the replies.
 
J

Joost Diepenmaat

exiquio said:
I should have been more clear. I need it to continue even if the mouse
isn't moving; as long the mouse is in the area of the trigger. Thanks
for the replies.

As long as you don't get a mouseout, the cursor is still over the
element.
 
E

exiquio

As long as you don't get a mouseout, the cursor is still over the
element.

That doesn't seem to work. The initial mouse over causes the event to
trigger, but there is not action to follow. I am using mootools for
this. Here is the code:

Code:
window.addEvent('domready', function(){
// Create a global namespace API
var SomeClient = function(){
/* PRIVATE */
// Create a scrolling object for the team box
var team_scroll = new Fx.Scroll(
'team_side_bar',
{
duration: 1000
}
);
var position = 0;
//var top_position =
document.getElements('div').filterByClass('profile_block')
[0].getPosition()['y'];
/* END PRIVATE */

/* PUBLIC */
return{
init: function(){
// Register events for team bar scrolling
// TODO (exiquio) adjust pixels
$('team_title').addEvent('mouseover', function(event){
//event = new Event(event).stop();
team_scroll.scrollTo(0, position - 116);
position = position - 116;
});
$('bottom_trigger').addEvent('mouseover', function(event){
//event = new Event(event).stop();
team_scroll.scrollTo(0, position + 116);
position = position + 116;
});
}
}
/* END PUBLIC */
}();
// Call init()
SomeClient.init();
});
 
J

Joost Diepenmaat

exiquio said:
That doesn't seem to work. The initial mouse over causes the event to
trigger, but there is not action to follow. I am using mootools for
this. Here is the code:

[snip]

You want some kind of timeout/interval event to scoll on while the mouse
hasn't move out of the element. I'm not familiar with the library you're
using. You also don't need
Code:
 tags to post code. This is usenet. We
tend to use plain text.
 
E

exiquio

exiquio said:
On Feb 25, 7:11 pm, Joost Diepenmaat <[email protected]> wrote:
That doesn't seem to work. The initial mouse over causes the event to
trigger, but there is not action to follow. I am using mootools for
this. Here is the code:

 [snip]

You want some kind of timeout/interval event to scoll on while the mouse
hasn't move out of the element. I'm not familiar with the library you're
using. You also don't need
Code:
 tags to post code. This is usenet. We
tend to use plain text.
[/QUOTE]

Thanks. My bad about the tags.
 
E

exiquio

exiquio said:
That doesn't seem to work. The initial mouse over causes the event to
trigger, but there is not action to follow. I am using mootools for
this. Here is the code:

You want some kind of timeout/interval event to scoll on while the mouse
hasn't move out of the element. I'm not familiar with the library you're
using. You also don't need
Code:
 tags to post code. This is usenet. We
tend to use plain text.[/QUOTE]

Thanks. My bad about the tags.[/QUOTE]

So here is the working code. I will change the intervals, but that
isn't important. Thanks Joost.

window.addEvent('domready', function(){
// Create a global namespace API
var JD = function(){
/* PRIVATE */
// Create a scrolling object for the team box
var team_scroll = new Fx.Scroll(
'team_side_bar',
{
duration: 1000
}
);
var position = 0;
/* END PRIVATE */

/* PUBLIC */
return{
init: function(){
// Register events for team bar scrolling
var topTriggerTimer = function(){};
var bottomTriggerTimer = function(){};
// TODO (exiquio) adjust pixels
$('top_trigger').addEvent('mouseenter', function(event){
topTriggerTimer = (function(){
team_scroll.scrollTo(0, position - 116);
position = position - 116;
}).periodical(1500);
});
$('top_trigger').addEvent('mouseleave', function(event){
$clear(topTriggerTimer);
});
$('bottom_trigger').addEvent('mouseenter', function(event){
bottomTriggerTimer = (function(){
team_scroll.scrollTo(0, position + 116);
position = position + 116;
}).periodical(1500);
});
$('bottom_trigger').addEvent('mouseleave', function(event){
$clear(bottomTriggerTimer);
});
}
}
/* END PUBLIC */
}();
// Call init()
JD.init();
});
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,825
Members
47,371
Latest member
Brkaa

Latest Threads

Top