Bug Tracker

Opened 9 years ago

Closed 8 years ago

#10229 closed enhancement (wontfix)

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

Reported by: mtaby@… Owned by:
Priority: low Milestone: None
Component: css Version: 1.6.3
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by Rick Waldron)

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.

Change History (11)

comment:1 Changed 9 years ago by addyosmani

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.

comment:2 Changed 9 years ago by pinzon@…


comment:3 Changed 9 years ago by dmethvin

Keywords: 1.8-discuss added

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

comment:4 Changed 9 years ago by sindresorhus


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)");

comment:5 Changed 9 years ago by jaubourg

Description: modified (diff)

-1, Feature creep.

comment:6 Changed 9 years ago by jzaefferer

-1, Too specialized

comment:7 Changed 9 years ago by dmethvin

Description: modified (diff)

-1, Nope.

comment:8 Changed 9 years ago by mikesherov

Description: modified (diff)

-1, feature creep

comment:9 Changed 9 years ago by timmywil


comment:10 Changed 9 years ago by Rick Waldron

Description: modified (diff)

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

comment:11 Changed 8 years ago by dmethvin

Keywords: 1.8-discuss removed
Resolution: wontfix
Status: openclosed

Voted off the island.

Note: See TracTickets for help on using tickets.