1

You can see the implementation here.

When you hover over any of the two big images, you see a little 'menu' set of icons appear. They are absolutely positioned right now.

I want them to function like a menu - so when you hover over the image, they appear to the top right of each of the images, i.e. when you hover over the left image, it appears in the top right corner of the left image, and when you hover over the right image, it does the same.

Also note that the images are on a carousel, so when you click next, the menu should disappear and you should get the menu on the next image that shows up too. Also why are those black dots appearing, is it because the images are list items?

How do I get rid of them?

Also, when you hover over the menu, it shouldn't flicker like it does now - and should allow me to be able to customize it like a menu (i.e. when they hover over each of the images, I can do an image swap to make it feel like a menu (even after one of the icons/buttons has been pressed).

Here is the requisite code....HTML:

<div id="slider-code">
    <a class="buttons prev" href="#"></a>
    <div class="viewport">
        <ul class="overview">           
            <li><img src="images/red-stripe.jpg" /></li>
            <li><img src="images/red-stripe-bw.jpg" /></li>
            <li><img src="images/red-stripe-red.jpg" /></li>            
            <li><img src="images/red-stripe-dark.jpg" /></li>
            <li><img src="images/red-stripe.jpg" /></li>
            <li><img src="images/red-stripe-red.jpg" /></li>
            <li><img src="images/red-stripe-dark.jpg" /></li>           
        </ul>

        <div id="edit-image-nav">
            <ul>
                <li><img src="images/comment-icon.png" /></li>
                <li><img src="images/paint-icon.png" /></li>
                <li><img src="images/delete-icon.png" /></li>
            </ul>
        </div>

    </div>
    <a class="buttons next" href="#"></a>
</div>

CSS:

#edit-image-nav {
    display: none;
}

#edit-image-nav ul {
    display: inline;    
    margin: 20px 0 auto; /* top, right, bottom, left */
    position: absolute; 
    z-index: 200;   
}

#edit-image-nav ul li {
    float: left;
}

JS

$(document).ready(function() {
    $("#slider-code .viewport .overview img")
        .hover(function() {
            $("#edit-image-nav").css({ 'display' : 'inline' });
        }, function() {
            $("#edit-image-nav").css({ 'display' : 'none' });
    });

});

Thanks.

marcamillion
  • 32,933
  • 55
  • 189
  • 380

4 Answers4

1

check into jquery ui position... http://jqueryui.com/demos/position/

very handy and it works pretty good.

user406905
  • 1,418
  • 15
  • 16
  • This looks neat...just not sure that it would work for what I am trying to do. Seems a bit 'overkill'. – marcamillion Dec 11 '10 at 01:07
  • awesome, looking at your link. For this setup to work you'll need to make your images `position:absolute` and add the mouse entere/leave to the li around it. As in this example (the `li` would be the `div` in this example) http://jsfiddle.net/subhaze/xbSZ6/2/ – subhaze Dec 11 '10 at 17:22
1

To the css you should add the top and right values so it can place them where you want them.

#edit-image-nav ul {
    display: inline;    
    margin: 20px 0 auto; /* top, right, bottom, left */
    position: absolute; 
    z-index: 200;   
}

Also, you may want to look into using mouseenter and mouseleave instead of hover (which behind the scenes uses mouseover and mouseout)

$('.element').mouseenter(function() {
    $("#edit-image-nav").css({ 'display' : 'inline' });
}).mouseleave(function(){
    $("#edit-image-nav").css({ 'display' : 'none' });
});

There is a reason to use mouseenter vs mouseout - it has to do with nested elements. You can see that here.

You can see the demos directly on mouseover and mouseenter.

Community
  • 1
  • 1
partkyle
  • 1,458
  • 1
  • 15
  • 25
  • Thanks for the tip on mouseover and mouseenter. The problem is that it still flickers when I am hovered over it. I think Tony's solution seems to be the closest so far. – marcamillion Dec 11 '10 at 01:05
1

If you want to show menu on each image try this:

CSS:


 ul.overview li {position: relative;}
#edit-image-nav {positon: absolute; display: none; right: 5px;}

JS:

$(document).ready(function() {
    var imageNav=$("#edit-image-nav").remove();
    $("#slider-code .viewport .overview img").mouseenter(function(event) {
            imageNav.insertAfter(this).css({ 'display' : 'block' });
        } ).mouseleave( function(event) {
            imageNav.css({ 'display' : 'none' }).remove();
    });
});
Tony Frolov
  • 213
  • 1
  • 9
  • This seems to take care of the flicker, the only thing is the placement is all weird. Right now, the menu appears in a vertical column about 20 px to the right of each of the images. Not in the top right hand corner. I guess I will continue playing with the CSS to get the positioning just right. – marcamillion Dec 11 '10 at 01:08
  • Maybe it would be better to set display: block; and right: 5px; to div#edit-image-nav – Tony Frolov Dec 11 '10 at 01:31
  • Also I've found on your code this: { margin: 20px 0 auto; /* top, right, bottom, left */ position: absolute; } I thought that margins doesn't work with position: absolute; – Tony Frolov Dec 11 '10 at 01:39
1

Something like this might work for you: Example

JavaScript used:

$('.overview li').mouseenter(function() {
    $(this).append($('#tool'));
    $('#tool').css('display', 'block');
}).mouseleave(function() {
    $('#tool').css('display', 'none');
});

HTML used:

<ul class="overview" >            
    <li><img src="http://fiwishop.com/feedback/images/red-stripe.jpg" ></li>
    <li><img src="http://fiwishop.com/feedback/images/red-stripe-bw.jpg" ></li>
    <li><img src="http://fiwishop.com/feedback/images/red-stripe-red.jpg" ></li>                
</ul>

<div style="clear:both"></div>
<div id="tool">[ ] [_] [X]</div>

CSS used:

.overview li{
    width:200px;
    height:135px;
    background-color:#666;
    float:left;
    margin:10px;
}
.overview li img{
    width:200px;
    position:absolute;
}
#tool{
    width:75px;
    background-color:#eee;
    display:none;
    position:relative;
    left:120px;
    top:5px
}
subhaze
  • 8,815
  • 2
  • 30
  • 33
  • Dude...this is exactly what I want....in terms of the functionality. Lemme see if it works. – marcamillion Dec 11 '10 at 17:05
  • Hey subhaze, I am still having problems. Creating a new jsfiddle now, so you can see. Gimme a few...don't disappear :) – marcamillion Dec 11 '10 at 17:27
  • No prob. I'm here. I made a comment but I guess I forgot to save it? Cause I don't see it. But after looking at the markup in your link you'll need to set the imgs to `position:absolute` and put the mouse enter/leave on the `li`. I've made a new example using your markup from link but changing out the widths to work better with jsfiddle http://jsfiddle.net/subhaze/xbSZ6/4/ – subhaze Dec 11 '10 at 17:32
  • Here we go: http://jsfiddle.net/QjUCt/ But it doesn't quite work like my live example - http://fiwishop.com/feedback/feedback-2.html - so the side scrolling don't work. Hope you can help me with this :) – marcamillion Dec 11 '10 at 17:32
  • have you tried implementing that link I put in my last comment? From the link you provided it still seems to be using your old code – subhaze Dec 11 '10 at 17:39
  • Sorry, I posted that before you updated. I just updated it and we are making progress. Refresh my live link, and you will see the icons appear, but they are all stacked on top of each other, rather than side by side. This is great progress though, almost there :) – marcamillion Dec 11 '10 at 17:41
  • 1
    I've updated the base fiddle to use a div with tool icons. they're all the 'delete' icon right now. But you should be able to change out as needed. Check it out and let me know! http://jsfiddle.net/subhaze/xbSZ6/ – subhaze Dec 11 '10 at 17:52
  • Brilliant! This works dude. One last kink....when you click on the '3-squares' icon, and hover over each of the images, the dimensions and stuff look weird. Any thoughts on how to solve that? http://fiwishop.com/feedback/feedback-2.html – marcamillion Dec 11 '10 at 18:06
  • 1
    Yea I believe it's where you have a huge width set for the image; `` take that out and just use CSS to adjust it globally – subhaze Dec 11 '10 at 18:11
  • Ok...I will try and track that down. Thanks man. Really appreciate all the help. – marcamillion Dec 11 '10 at 18:18
  • cool, glad I could help! I updated the base fiddle again to wrap everything in a closure which will keep track of what image was moused over so you can do what you need with it. – subhaze Dec 11 '10 at 18:22