Jump to content
Search Community

Dragging when a div in front...

mimeartist

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

mimeartist
Posted

I've got a draggable background, but it needs to have an transparent layer of small dots (which I'm using a transparent .png for) over the front that don't move... I know this isn't strictly a gsap issue... but is there a way to drag a div that is below a div you don't want to move?

Posted

Hello mimeartist,

 

If I understand you correctly.. you want to make it so an element doesn't  accept any events? ..

 

You could do this with just CSS using pointer-events:

#element {
      pointer-events:none; // disable mouse events on element
}

pointer-events:none will stop the element from receiving any mouse events. Which in turn allows you to click through the element, and click the element below it.

 

pointer-events: https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events

 

Let us know if this doesn't answer your question? :)

  • Like 1
Posted

Yep, I'd guess jonathan's suggestion is right-on, and if for some reason you don't want to follow that advice, you could try defining the dots as the "trigger" on the Draggable. 

Draggable.create("#background", {trigger:"#dots"});
  • Like 1
Posted

Nice Jack... I forgot about the trigger parameter :)

Posted

Here's a little sample of Draggable's trigger made some time ago:

 

See the Pen IiHgq by rhernando (@rhernando) on CodePen.

  • Like 1
Posted

Yes awesome Jamie, but from that link it looks like IE11 supports it.. but your link got me thinking of the versions of IE that don't support it..  very long list :)

 

Try this JS pointer-events kludge for CSS pointer-events support in IE10 and below:

 

See the Pen BriCb by jonathan (@jonathan) on CodePen.

 

Let me know if your able to still click through the red moving bar in IE10 and below when the checkbox is checked.

 

Thanks

mimeartist
Posted

Wow... thanks for these... will give it a whirl and let you know how I get on. I'll need to have it working on lower versions of IE so probably will have to try the trigger route.

  • 1 month later...
Posted

Is there a way to pass an element to "trigger" that is not a child? Is there a reason that it is children only?

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...