Jump to content
Search Community

Draggable how to set width manually

LucitheR 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 there,

 

Draggable constructs a div around the content of my Element(s). 

One of those changes the width while dragging horizontal. i know the end position of that element before creation of the Draggable. 

how can i set the width of the draggable div during creation (i presume 'padding-right' ?), to avoid empty space at the drag end?

 

 

<div id="scroll__window" class="scroll__window" style="overflow-x: auto; overflow-y: hidden; cursor: move; touch-action: pan-y; user-select: none;">
<!-- // injected by draggable this padding-right needs to be set manually -->
<div style="display: block; width: 100%; padding-right: 18836px; position: relative; overflow: visible; vertical-align: top; transform: translate3d(0px, 0px, 0px);">

          <div class="stories__wrapper">
        	<div class="stories__container"> 
        	<!-- Stuff -->	
            </div>
            <div id="scroll__container" class="scroll__container">
              <!-- even MORE Stuff  absolute positioned & parallax -->	
            </div>
          </div>

      </div>
      
</div>

 

(Sorry have not the time for a codepen :(

 

maybe there is a simple answer, i'm not yet aware of?

 

 

  

Link to comment
Share on other sites

Hi Jack thanks for the Reply,

 

we are currently building a horizontal website with a parallax (3 layers) in it, these layers are completely under control of the customer , so we don't know how long these are, what is on them, etc. (i have no permission to share any more code)

 

When you scroll/drag to the end you have massive amount of emptiness (since all layers moved to the left), so i needed to cut it after the last visible element. I calculated the width the page will have after animations and dragging. 

 

My question was how to override the padding  that will be set in the calibrate function (line ~1039) of Draggable.js  and here:

 

	extraPadRight = Math.max(0, element.scrollWidth - element.clientWidth);

 

 

 

i know this is not a normal use case ;) but i thought i ask for any un(der) documented feature before

i start to hack Draggable.js  (hacking it is evil, dirty and really ugly)

 

i think it would be nice to have a feature to set a custom width to the draggable container when creating the Draggable or in scrollProxy.

 

i will provide a link to the site when it's live.

 

 

Cheers, Jan

 

 

 

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