Bug Tracker

Ticket #10229 (closed enhancement: wontfix)

Opened 3 years ago

Last modified 3 years 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 3 years 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 3 years ago by pinzon@…

+1

comment:3 Changed 3 years ago by dmethvin

  • Keywords 1.8-discuss added

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

comment:4 Changed 3 years 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 3 years ago by jaubourg

  • Description modified (diff)

-1, Feature creep.

comment:6 Changed 3 years ago by jzaefferer

-1, Too specialized

comment:7 Changed 3 years ago by dmethvin

  • Description modified (diff)

-1, Nope.

comment:8 Changed 3 years ago by mikesherov

  • Description modified (diff)

-1, feature creep

comment:9 Changed 3 years ago by timmywil

-1

comment:10 Changed 3 years ago by rwaldron

  • Description modified (diff)

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

comment:11 Changed 3 years ago by dmethvin

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

Voted off the island.

Note: See TracTickets for help on using tickets.