Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to specify units as "pixels" or "percentage" #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bcole808
Copy link

Great jQuery plugin!

I am using block elements with an intrinsic aspect ratio in order to display responsive image spaces where the user has adjusted the image position using this jQuery plugin.

Problem

Background images positioned using pixels and background-size: cover only look correct when the image container remains exactly the same size.

Solution

Using percentages for background position allows the background to be in the correct space, regardless of element size.

Implementation

The code I added to the plugin adds an option called units which lets the developer specify "pixels" or "percent" and if percent is configured then the plugin will convert to percent before applying the styles.

@julianlam
Copy link

Are there plans to get this merged? Would be backwards compatible if "px" is defaulted if no units are passed in.

This is important for my use case, where a dragged picture's position changes significantly if the background-size is set to cover, as when browser is resized, the dimensions of the image itself have changed, but the saved position is still in reference to the old image dimensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants