Jquery / JS Help
- Started
- Last post
- 8 Responses
- ESKEMA
Hi,
I want to establish a relation between a dynamic height and a 0-100 value.
So, at the original height state, the value would be passed as 100, and as the height decreases (up until 60px), the value would come down to 0.something like:
$something(100) = height (300)
when height changes to lets say (150) then $something's value would be 50...
How could I achieve something like that. I'm sure it must be quite easy but my knowledge is too limited to get there..
Cheers for any help
- chrisRG0
max = 300; // initial (max) value
min = 60; // minimum drag value
pos = 150; // slider positionpercentage = ((pos-min) / (max-min))*100; // 37.5%
- ESKEMA0
Cheers chrisRG, I got it working with a variation of what you gave me,
but now for something else, I don't know why this is not working:$(this).css({"opacity": $opac+'%'});
If I remove the +'%', then it displays the correct value, with it, it gets completely ignored..
any idea?
Thanks again for the help. Much appreciated
- i tried several syntax variations, all with the same result...ESKEMA
- ESKEMA0
bah, my bad. Opacity doesn't use percentage..
dumbfuck
- georgesIII-2
Why don't you use @media tag
e.g.@media (max-width: 640px) {
do something;
}- because that has nothing to do with what I want :)ESKEMA
- falcadia0
PonyBoy is right. I used these prototypes not long ago as the starting point for something similar. All you need is something to give you the values to check against.
- falcadia3
I kid. Here is a quick and dirty prototype using jQuery UI. Hopefully set you in the right direction.
- Great thanks, I'll show this to my client. If he likes the overall approach, I'll get him to pay you to create the real thing!utopian
- BTW - how much would it cost to create one of these, 5-10 images? Is the slider customizable? And will this responsive?utopian
- stick to the $10k, falcadia :)PonyBoy
- ^haha... I wrote that after refreshing... now that he asked.. $20k
http://cdn.meme.am/i…PonyBoy - Geez, I thought I was helping a fellow QBN'r figure out some code. Now you're offering me a gig for $10K? Let me get you my personal email.falcadia
- All seriousness though, this was a 20 min proof of concept. There are much better ways to pull this off. We can discuss.falcadia
- what is your email?utopian
- Send me a DM on twitter. @digitalcraftco. Don't want to burn an email on here.falcadia