Skip to main content

Bug Tracker

Side navigation

#10229 closed enhancement (wontfix)

Opened September 08, 2011 05:28PM UTC

Closed January 18, 2012 03:27AM UTC

Relative value syntax (for .css() and .animate()) should support more mathematical operations

Reported by: mtaby@me.com Owned by:
Priority: low Milestone: None
Component: css Version: 1.6.3
Keywords: Cc:
Blocked by: Blocking:
Description

Right now, you can set a css property relative to a current value. However, I think jQuery ought to support multiplication and division as well.

Use-cases for this vary, in my case, I want to set the scale (3d/2d transformation) relative to its current position, but scale is a multiplier, not a static value; You don't "add one" to a scale, you "multiply by 1.01".

Another use-case is when someone wants to double/triple the current value, same with halving, dividing, etc.

From my casual peek at the code, it seems like this would involve small changes to the rrelNum regex in css.js and some corresponding changes to the style() method.

Attachments (0)
Change History (11)

Changed September 09, 2011 03:49PM UTC by addyosmani comment:1

component: unfiledcss
priority: undecidedlow
status: newopen

Opening up for discussion/voting. imo, this can be achieved with custom workarounds, but I'll see what others have to say about it.

Changed September 09, 2011 08:54PM UTC by pinzon@apple.com comment:2

+1

Changed October 05, 2011 09:20PM UTC by dmethvin comment:3

keywords: → 1.8-discuss

I'm not a fan but will put it up for discussion.

Changed December 06, 2011 08:54PM UTC by sindresorhus comment:4

-1.

You can easily do this already:

$("div").css("margin", function( i, val ) {
    return val * 0.666;
});

If we do this, expect requests for even more advanced math :P

$("div").css("margin", "(sqrt(cos(x))*cos(200*x)+sqrt(abs(x))-0.7)*(4-x*x)^0.01,sqrt(9-x^2),-sqrt(9-x^2)");

Changed December 13, 2011 04:09PM UTC by jaubourg comment:5

description: Right now, you can set a css property relative to a current value. However, I think jQuery ought to support multiplication and division as well. \ \ Use-cases for this vary, in my case, I want to set the scale (3d/2d transformation) relative to its current position, but scale is a multiplier, not a static value; You don't "add one" to a scale, you "multiply by 1.01". \ \ Another use-case is when someone wants to double/triple the current value, same with halving, dividing, etc. \ \ From my casual peek at the code, it seems like this would involve small changes to the `rrelNum` regex in css.js and some corresponding changes to the style() method.Right now, you can set a css property relative to a current value. However, I think jQuery ought to support multiplication and division as well. \ \ Use-cases for this vary, in my case, I want to set the scale (3d/2d transformation) relative to its current position, but scale is a multiplier, not a static value; You don't "add one" to a scale, you "multiply by 1.01".\ \ Another use-case is when someone wants to double/triple the current value, same with halving, dividing, etc.\ \ From my casual peek at the code, it seems like this would involve small changes to the `rrelNum` regex in css.js and some corresponding changes to the style() method.

-1, Feature creep.

Changed December 13, 2011 05:11PM UTC by jzaefferer comment:6

-1, Too specialized

Changed December 13, 2011 06:26PM UTC by dmethvin comment:7

description: Right now, you can set a css property relative to a current value. However, I think jQuery ought to support multiplication and division as well. \ \ Use-cases for this vary, in my case, I want to set the scale (3d/2d transformation) relative to its current position, but scale is a multiplier, not a static value; You don't "add one" to a scale, you "multiply by 1.01".\ \ Another use-case is when someone wants to double/triple the current value, same with halving, dividing, etc.\ \ From my casual peek at the code, it seems like this would involve small changes to the `rrelNum` regex in css.js and some corresponding changes to the style() method.Right now, you can set a css property relative to a current value. However, I think jQuery ought to support multiplication and division as well. \ \ Use-cases for this vary, in my case, I want to set the scale (3d/2d transformation) relative to its current position, but scale is a multiplier, not a static value; You don't "add one" to a scale, you "multiply by 1.01". \ \ Another use-case is when someone wants to double/triple the current value, same with halving, dividing, etc. \ \ From my casual peek at the code, it seems like this would involve small changes to the `rrelNum` regex in css.js and some corresponding changes to the style() method.

-1, Nope.

Changed December 14, 2011 12:57AM UTC by mikesherov comment:8

description: Right now, you can set a css property relative to a current value. However, I think jQuery ought to support multiplication and division as well. \ \ Use-cases for this vary, in my case, I want to set the scale (3d/2d transformation) relative to its current position, but scale is a multiplier, not a static value; You don't "add one" to a scale, you "multiply by 1.01". \ \ Another use-case is when someone wants to double/triple the current value, same with halving, dividing, etc. \ \ From my casual peek at the code, it seems like this would involve small changes to the `rrelNum` regex in css.js and some corresponding changes to the style() method.Right now, you can set a css property relative to a current value. However, I think jQuery ought to support multiplication and division as well. \ \ Use-cases for this vary, in my case, I want to set the scale (3d/2d transformation) relative to its current position, but scale is a multiplier, not a static value; You don't "add one" to a scale, you "multiply by 1.01".\ \ Another use-case is when someone wants to double/triple the current value, same with halving, dividing, etc.\ \ From my casual peek at the code, it seems like this would involve small changes to the `rrelNum` regex in css.js and some corresponding changes to the style() method.

-1, feature creep

Changed December 14, 2011 04:06PM UTC by timmywil comment:9

-1

Changed December 19, 2011 05:27PM UTC by rwaldron comment:10

description: Right now, you can set a css property relative to a current value. However, I think jQuery ought to support multiplication and division as well. \ \ Use-cases for this vary, in my case, I want to set the scale (3d/2d transformation) relative to its current position, but scale is a multiplier, not a static value; You don't "add one" to a scale, you "multiply by 1.01".\ \ Another use-case is when someone wants to double/triple the current value, same with halving, dividing, etc.\ \ From my casual peek at the code, it seems like this would involve small changes to the `rrelNum` regex in css.js and some corresponding changes to the style() method.Right now, you can set a css property relative to a current value. However, I think jQuery ought to support multiplication and division as well. \ \ Use-cases for this vary, in my case, I want to set the scale (3d/2d transformation) relative to its current position, but scale is a multiplier, not a static value; You don't "add one" to a scale, you "multiply by 1.01". \ \ Another use-case is when someone wants to double/triple the current value, same with halving, dividing, etc. \ \ From my casual peek at the code, it seems like this would involve small changes to the `rrelNum` regex in css.js and some corresponding changes to the style() method.

-1, Give an inch and they'll take a mile. Feature creep

Changed January 18, 2012 03:27AM UTC by dmethvin comment:11

keywords: 1.8-discuss
resolution: → wontfix
status: openclosed

Voted off the island.