error offset().left in null or not an object [duplicate] - javascript

I have a menu system made up of divs and i want to animate the left property to slide each time the user mouses over a menu item but i need the outer div(which is black) element to expand as the menu items move left to right also I want the div element(.container) to slide back and contract the outer div element(this black div which is 0 width) I have a basic example done in jsFiddle it olny moves the elements to the left

Having a little trouble fully understanding, but is this sort of what you mean?
http://jsfiddle.net/V3RHr/2/

If I could rewrite your html a bit, I would put make each .menu-item into an unordered list.
When you mouseenter the unordered list, you expand the second container. Inside that mouseenter function, I would have a second event when you mouseenter a list item, you populate the second container and stopPropogation.
You could probably still do it with a mouseenter on the first container, and another mouseenter on the div.menu-item, but your first container has extra height and width.

You should be able to fix the left is null issue by having the code not execute on the last .content, like this:
$('.container').not(':last').find('.menu-item').mouseenter(function () {
This will not apply to the menu-items within the green box.
For the re-show issue, I would change the way you are showing. Instead of sliding the box out from behind the other, you can position it where you want it to end up and hide it, then you can use:
.animate({width: 'show'})
Which will give a similar sliding effect.
That, or do it similar to my response to your other question, only without the collapsing I had previously:
http://jsfiddle.net/V3RHr/3/

Related

jQuery hover repositions on subsequent hovers

I have a hover event set on an element that use's jQuery UI's position function to show a div right underneath it, with the "out" set to hide that div.
The problem is, subsequent hovers position that div further and further on each hover.
Example: http://jsfiddle.net/Shpigford/8ZkgJ/
Hover over the red box, then hover over it again and you'll see the blue box quickly get positioned further and further to the right.
Same thing happens if I change to a click event. Seems like something odd is happening with positioning when I hide the div and then try to show it again.
Instead of position({...}).show(), use show().position({...}). The reason is that positon won't work when the element is invisible. You can find the following note at http://api.jqueryui.com/position/:
jQuery UI does not support positioning hidden elements

JavaScript (w/jQuery) - grow an element to fill container on hover, when surrounded by other elements

I have a grid of elements (3 x 3) formation which toggle visibility on hover, easy.
However my next step is to grow said elements to fill their container when hovered upon, I'm assuming I would need to get current (x,y) values and then grow this to the (x,y) values of the parent container and use css positioning, however every approach I take is hitting a brick wall. I have a fiddle here which demonstrates the layout / intended functionality - http://jsfiddle.net/u2w7J/
Any help would be gratefully appreciated!
The way your HTML is set up currently, this is kind of hard to accomplish while having it look smooth. A first try is to use the .toggleClass function and toggle "box" and "miniBox" for the hovered element. See http://jsfiddle.net/u2w7J/6/ for a demo.
Positioning is harder since the miniBoxes are not positioned absolutely. Hence, adding animation is causing weird results (see above demo).
I would suggest to have the miniBoxes positioned absolutely. When hovering, get the parents div left and top values and animate the miniBox using these values. Additionally, raise z-index during or before the animation to prevent other miniBoxes being visible.

if cursor inside div then display block jquery

Here is a jsfiddle of the problem:
http://jsfiddle.net/MEJgb/
I want it so when you hover over anywhere in the footer the toggledown will become active and will remain active until you move the mouse from the footer.
Your problem is the following line:
jQuery('html,body').animate({
scrollTop: jQuery("#footer_copy_right").offset().top
}, 'slow');
This causes the whole page to move adn thus the item you were hovering over is no longer being hovered over so it triggers your event again and hides your text. When I was testing this was causing the hover content to move back under my mouse and thus trigger again...
I would personally not use hover in this situation and let the user click to expand and then click again to collapse.
If you want to keep using the hover option then you need to decide what the event to trigger the collapse should be. Clearly the current choice (mouse no longer over the arrow) is insufficient.
Often what I will do is attach the hover to a block containing the visible triggering block as well as the contents that are going to be displayed. This way your content won't collapse until you have moved off the newly displayed content.
http://jsfiddle.net/AjHwM/ is an example of such a thing.
Even if I'm not sure what your actual goal is, maybe the document.elementFromPoint() method is what helps you out here.
It is invoked like
if( document.elementFromPoint( event.pageX, event.pageY ) === $('#footer')[0] ) { }
That code, within your hover aka mouseenter / mouseleave handlers, would compare the node which lays under the current absolute mouse cursor X/Y positions against the #footer node.
Ref.: MDN doc, W3C doc

Jquery Flipcard Animation to flip on toggle event

I have a simple jquery flipcard animation - http://jsfiddle.net/gGAW5/36/
Now the way this flip card works is it shows the top div, and hide all divs below it. IF you click on a link in the first div, it flips to the second div andsoforth.When it gets to the last div, it flips back the the first one again on clicking an anchor tag. Now I want 3 anchor tags on the front flip card(first div) and each link(a tag) should have its own back flip card/backsideDiv. currently, in my example, when you click on the first link, it loops through the other 2 links' backsideDivs/flipcards as well. I want it to go back to the main front div again(not flipping to the other links' backflip divs).
So each set of anchor tag/back div pair should operate independently. Hoped I explained it well enough.
I would really appreciate any help
Thank You
There isn't much of easy use of functions for quickFlip... This isn't pretty, but I think I got what you're looking for or at-least close. http://jsfiddle.net/2WbYG/10/

jQuery - Only Call The Hover Out Function if Cursor Isn't Entering Any Siblings

I'm trying to create an effect similar to the navigation on this site: http://rogwai.com/. I'm fairly close as you can this in this jsFiddle.
It's working fine if you hover into one li at a time (i.e. from the bottom). If however, you slide horizontally through each list item the 'follower' returns to the active position or slides of the end after each item that's hovered over. Instead it should follow the mouse.
Looking at the code executed on hover out this is completely understandable. What I can't get my head around is how to make it only return to the active position or slide off the end when the mouse completely leaves the menu.
Hopefully that makes sense - you should see the problem straight away from the jsFiddle.
Thanks in advance.
What you can do is add the mouseenter part to the li as you have it, but put the mouseleave part on the entire ul. This way, the leave will only fire when you mouse out of the entire ul.
http://jsfiddle.net/YZr5b/6/
$('nav.block-system-main-menu ul li:not(.follower)').mouseenter(function() {
followerMove($(this));
});
$('nav.block-system-main-menu ul').mouseleave(function(){
followerMove($active);
});
Note, if you are really using jquery 1.2.6 (quite old), you will need to modify this a bit as mouseenter and mouseleave do not exist.

Categories