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

Accept Percentage Values for Transform #38

Open
grayghostvisuals opened this issue Mar 6, 2014 · 7 comments
Open

Accept Percentage Values for Transform #38

grayghostvisuals opened this issue Mar 6, 2014 · 7 comments

Comments

@grayghostvisuals
Copy link

Just like the title says. I do off canvas type animations moving things out and then back into the viewport using percentage values from time to time. Would be great to accept percentage values for transforms instead of just pixels.

@muhammad-saleh
Copy link

I know that this might be a bit late
but I was able to make it accepts percentages (percentages only not percentages and pixels)
by going to line 242 which has " case _translate: " and change the unit for the translate feature from px to %

And I guess you can do the same with the rest of the features

@grayghostvisuals
Copy link
Author

@muhammad-saleh Nice. That works. Still needs a way to determine if percentages are used or pixels are used so the author is not tied to one or the other.

@muhammad-saleh
Copy link

Okay... as a quick fix
go to the same line which has the unit and change it
from:
unit = "px";
to
unit = $.transform.transformUnit || "%";

Now it will check for the value of $.transform.transformUnit if it's found the plugin will use it and if not it will fallback to %

Usage:
before you start using the plugin do this
$.transform.transformUnit = "%";
and after that you can use the plugin and whatever string you will add it will be passed through as it is

so you can use % or px or vh ...etc

Hope I helped

@grayghostvisuals
Copy link
Author

So we're saying line 242 replace that line with this…

unit = $.transform.transformUnit || "%";

I'm still confused where you are saying to put this line…

Usage:
before you start using the plugin do this
$.transform.transformUnit = "%";
and after that you can use the plugin and whatever string you will add it will be passed through as it is so you can use % or px or vh ...etc

@muhammad-saleh
Copy link

I meant in the document.ready event

@grayghostvisuals
Copy link
Author

gotchya. hmmm..kind of seems that way an author needs to change the val w/$.transform.transformUnit = "%"; depending on the case. I feel like it could be a bit more dynamic with the value passed. I appreciate the help and guidance so far btw.

@muhammad-saleh
Copy link

I'm glad that I can help :)
I think that this is the best solution cause this will pass whatever you input as a unit
However I didn't go through the other features but as for the transformation I think it should work fine now

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

No branches or pull requests

2 participants