Jump to content
Search Community

Draggable Div Containing List Anchors

drmcgog test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi!

Just a push in the right direction would be very helpful.

 

I am trying to make a simple thumbnail gallery (will be colorbox.js powered)

draggable horizontaly for screen and touch.

 

I read in the description that drags vs clicks are detected,

however I cannot figure out how to create this functionality.

 

Drag only works when the containing div is dragged,

not the thumbnails, it contains.

 

How can I set this up so that the entire gallery is

draggable unless a thumb is clicked

or is there a simple solution that i am overlooking?

 

 

I have created a codepens:

 

See the Pen bhtLp by anon (@anon) on CodePen

 

See the Pen fuoki by anon (@anon) on CodePen

 

 

 

 

 

HTML

 

<div class="gallery_block">
<ul class="thumbnail_list">
<li>
</li>
</a>
<li>
</li>
</a>
<li>
</li>
</a>
<li>
</li>
</a>
<li>
</li>
</a>
<li>
</li>
</a>
<li>
</li>
</a>
</ul>
</div>
 
 
 
CSS
 
.gallery_block {
  float: left;
  width: 500px;
  height: 400px;
  border: 1px solid #bebebe;
  overflow: hidden;
}
 
.thumbnail_list {
  float: left;
  width: 800px;
  height: 100%;
  list-style: none;
}
 
.thumbnail_list li img {
  float: left;
}
 
.thumbnail_list a {
  margin-right: 5px;
  margin-bottom: 5px;
  float:left;
 
}

 

 

JS

 

<script>
 
var gridWidth = 150;
Draggable.create(".thumbnail_list", {
type:"x",
edgeResistance:1.0,
});
Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

By default Draggable allows the default event in <a> tags, which your images are contained in, so in the codepens, as you describe the drag is ignored on this elements. In order to prevent this you have to include in your Draggable instance dragClickables:true, like this:

Draggable.create(".thumbnail_list",
{
  type:"x",
  edgeResistance:1.0, 
  dragClickables:true
}) 

Rodrigo.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...