Jump to content

Recommended Posts

Hey guys, 
I modified a script that i found on the web and and i'm trying to use it as a thumbnail gallery scroller (for lack of better words).
The problem i'm running into right now is that when i click either the left or the right buttons all of the boxes scroll. I'm trying to use the (this) "selector" but i'm having trouble figuring it out can someone perhaps help me a bit with this one? would be greatly appreciated.

 

Here's the html.

<div class="container">
<div class="arrowL"><img  src="left.png"    width:'20';
    height:'100'; />
</div>
<div class="arrowR"><img src="right.png"    width:'20';
    height:'100';/>
</div>
<div class="list-container">
    <div class='list'>
        <div class="item">
        </div>
            <div class="item">
        </div>
            <div class="item">
        </div>
            <div class="item">
        </div>
            <div class="item">
        </div>
            <div class="item">
        </div>
	</div>
</div> 
     
    </div>

The css.

.item{ background-color:#FFFFFF;
    width:120px;
    height:90px;
    margin:5px;
    float:left;
    position:relative;
}
 .container{
width:1000px;
height:100px;
}
.list-container { 
display:inline-block;
overflow:hidden;    
width: 960px;  
float:left;    
}
.list{
    background:grey;
min-width:1500px;
    float:left;
}
.arrowR{
    width:20px;
    height:100px;
    float:right;
    cursor:pointer;
	opacity:0.5;
}
.arrowL{
    width:20px;
    height:100px;
    float:left;
    cursor:pointer;
opacity:0.5;
}

And the js.

<script>
$(document).ready(function() {

    var $item = $('div.item'),
        visible = 7,
        index = 0, 
        endIndex = ( $item.length / visible ) - 1; 

    $('div.arrowR').click(function(){
        if(index < endIndex ){
          index++;
          $item.animate({'left':'-=300px'});
        }
    });

    $('div.arrowL').click(function(){
        if(index > 0){
          index--;            
          $item.animate({'left':'+=300px'});
        }
    });
});
</script>

Anyone know what i'm doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/277916-animate-one-at-the-time/
Share on other sites

Hey newhip,

 

the entindex is equal to "(6 / 7) -1", so you will get a negative number as a result and that statement has never been executed - if(index < endIndex ) b/s the index is set to zero!

 

I don't know what exactly your code is doing but after a quick check yesterday night I saw that error.

 

PS: A nice cat, I have a one which weights 15 pounds :)  

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.