Jump to content
Search Community

Gsap Draggable will not initialize below bottom of window viewport

BearAxe test
Moderator Tag

Go to solution Solved by BearAxe,

Recommended Posts

Problem: I have a game i'm trying to create where you basically have a bank of boxes that you drag up to match with a hitbox. initially, these draggable elements are at the bottom of a layout that may be longer than the height of the viewport. However, I noticed while trying to place the boxes that the boxes will initialize to the bottom of the screen instead of to where i'm setting the y coordinate.

 

Want: I would like to know if there's a way to force the transform down below the bottom of the viewport so that when i scroll down, i see the bank of draggable elements positioned to where i set the coordinates using the level coordinate map. is this possible?

 

I've added a minimal demo of the issue in the attached code pen. see how box4 is set to y coord 10276 and how it is flush at the bottom with boxes 2 and 3 with y coords 1176 and 1110. I would expect box4 to initialize below bottom of the viewport in this case. can i trick it into doing this somehow?

See the Pen RwJjJvz by skaulox (@skaulox) on CodePen

Link to comment
Share on other sites

  • Solution

Well, it turns out i didn't read the docs closely enough!

This was caused by me using window as the bounds. If i replace bounds: window with the container's class name, this works exactly how I was hoping it would. 

 

Love when I find the answer right after asking for help 😆 Hope someone else finds this useful!

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