Bug Tracker

Modify

Ticket #10229 (closed enhancement: wontfix)

Opened 21 months ago

Last modified 16 months ago

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:
Blocking: Blocked by:

Description (last modified by rwaldron) (diff)

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

comment:1 Changed 21 months ago by addyosmani

  • Priority changed from undecided to low
  • Status changed from new to open
  • Component changed from unfiled to css

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 21 months ago by pinzon@…

+1

comment:3 Changed 20 months ago by dmethvin

  • Keywords 1.8-discuss added

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

comment:4 Changed 18 months ago by sindresorhus

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

comment:5 Changed 17 months ago by jaubourg

  • Description modified (diff)

-1, Feature creep.

comment:6 Changed 17 months ago by jzaefferer

-1, Too specialized

comment:7 Changed 17 months ago by dmethvin

  • Description modified (diff)

-1, Nope.

comment:8 Changed 17 months ago by mikesherov

  • Description modified (diff)

-1, feature creep

comment:9 Changed 17 months ago by timmywil

-1

comment:10 Changed 17 months ago by rwaldron

  • Description modified (diff)

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

comment:11 Changed 16 months ago by dmethvin

  • Keywords 1.8-discuss removed
  • Status changed from open to closed
  • Resolution set to wontfix

Voted off the island.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.