Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Cor

Positioning problem

Recommended Posts

I have a problem getting image tweened in the correct position.
The filmstrip width is 1920 px.

When images are positioned staticly the first left is 20 px.

Every picture width is 200 px.

The space between 2 images is 40 px.

But when tweening images into place, the position is not correct.

Why?

Or what am I doing wrong?

 

Link to comment
Share on other sites

Hello Cor and Welcome to the GreenSock Forums!

 

This is just an issue with CSS setup. Here is an example of the images aligned on the filmstrip:

 

See the Pen IrpaE by jonathan (@jonathan) on CodePen

 

What i did was:

  • i created a rule for #banner and added position:relative to the #banner div so this way the absolutely positioned children are absolutely positioned relative to its parent (#banner)
  • I added float:left and changed display:inline-block to display:block to your #banner div selector (since you have a width and height defined for #banner div selector than it is better to use display:block due to browser bugs with display:inline-block)
  • I also added top:0px  and left:0px to #banner_bg to make sure it set at default top 0 and left 0
     

I hope this helps! :)

  • Like 1
Link to comment
Share on other sites

Thanks Jonathan!

I guess defining the width and height is probably not a good approch, because I want to use this in a responsive website.
What would be the proper way to do this?

Link to comment
Share on other sites

Glad to help.. I don't have time at the moment for setup as responsive. But if you look at this Blog article by GreenSock regarding xPercent and yPercent i'm sure you can come up with something until i have time to debug and test.

 

http://greensock.com/gsap-1-13-1

 

GSAP xPercent and yPercent are awesome for responsive animation goodness! :)

  • Like 1
Link to comment
Share on other sites

Yes, I have seen that, and will try to implement it.

 

Looking forward to your solution...

 

Thanks again!!

Link to comment
Share on other sites

Hi Cor,

 

It sounds like it could be quite a challenge to get each individual image to resize, move, and maintain aspect ratio as your filmstrip image is being scaled.

You original post mentioned very specific widths and spacing parameters in pixels (which is what Jonathan provided a solution for). Making it responsive however requires a lot more work on the css side.

 

 

I would probably recommend against using the long film-strip image and just create the whole thing using responsive css. Unfortunately, doing elaborate responsive layouts is a bit beyond our core focus on the GSAP api.

 

Here is an example that might work as a starting point for getting the film-strip images to be responsive, as opposed to being in a long static image: http://codepen.io/GreenSock/pen/5821c202caac77d1d04ffc67bc50b1cb/

 

resize your window as the animation plays. 

  • Like 2
Link to comment
Share on other sites

Hi Carl,

 

CSS is really my worst field.

I understand the challenge, in fact I was thinking of it a good part of the night.

FYI, I use bootstrap as framework and now trying to get around some GSAP usage.

 

So just out of bed, I was thinking of trying it in GSAP with scale on update or something like that?

 

Now the www-world is getting more and more into responsive design and mobiles first, I think I spot a GSAP-challege...

 

Maybe it is a good idea to extend GSAP to a full (responsive) framework... :oops:

That would be shockingly green! :mrgreen:

 

Thanks for your support and I hope you guys continu the challenge!!

Link to comment
Share on other sites

Thanks Carl, your pen is the solution!

I had it working within 30 minutes.

 

I started to tune it so it gets clever....

And then I screwed something up badly without having a roll back. :ph34r:

And restoring it, made everything worse!!! :angry:

So Murphy's Law works!!! :lol:

 

OK, I have it working again and responsive.

But there is a little twitch.

When the screen is resized to any smaller then 100%, the images give a sort of after effect.

It is not because of force3D:true.

 

Is this due to percentage resizing and images having a floating point size?

 

I just created a pen so others can benefit when using Bootstrap: 

See the Pen bBHGj by codo (@codo) on CodePen

 

Please feel free to correct this!!

 

Next steps is a great array with pictures and they switch randmly in the filmstrip.

Suggestions up front are welcome!

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