Jump to content
Search Community

Animate css Object-Position using Draggable

Aron H test
Moderator Tag

Recommended Posts

I am wanting to make an image viewer where I can drag an image positioned absolutely within a square container to view more of the image. I got it working if I set the image height to 'auto'. However, I want to use 'height: 100%' and 'object-fit: cover' on the image so I can maximize how much is viewed at one time. Since width and height are both set to 100%, no drag events ever fire. How can I animate the 'object-position' css property instead of the image x & y coordinates?

See the Pen YzMmMqE by Aron-Hawkins (@Aron-Hawkins) on CodePen

Link to comment
Share on other sites

Hi @Aron H and welcome to the GSAP Forums!

 

I'm not sure I understand what you're trying to do here, maybe something like this:

See the Pen LYdRQra by GreenSock (@GreenSock) on CodePen

 

Hopefully this helps, if not please provide a clear description of what you're trying to do so we can get a better idea.

Happy Tweening!

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