Skip to content

Support for relative values for $().css setters (#7345)#78

Closed
brandonaaron wants to merge 1 commit intojquery:masterfrom
brandonaaron:7345
Closed

Support for relative values for $().css setters (#7345)#78
brandonaaron wants to merge 1 commit intojquery:masterfrom
brandonaaron:7345

Conversation

@brandonaaron
Copy link
Contributor

This is for ticket #7345. Supporting +=/-= for setting values in $().css.

We might want to share the rrelnum regex with the rfxnum regex from effects.js since they are the same.

Also, this patch doesn't really take other units than pixels into consideration.

@csnover
Copy link
Member

csnover commented Nov 21, 2010

Is there a way this could be combined with the pre-existing code in effects.js instead of copy-pasting duplicate code?

@csnover
Copy link
Member

csnover commented Dec 27, 2010

Closing after 30 days of no response from submitter.

@jswartwood
Copy link

Just a thought to get rid of that (parts[1] === "-=" ? -1 : 1) test...

change regex:
rrelnum = /^(?:([+-])=)?([\d+.-]+)(.*)$/,

css.js
value = parseFloat(parts[1] + parts[2]) + jQuery.css(elem, name);

and possibly... effects.js
end = parts[1] ? parseFloat(parts[1] + parts[2]) + start : parseFloat(parts[2])

@danheberden
Copy link
Member

A newer version of this pull req can be found at #297 - Changed the way it parses the string and wrote some improved tests.

krunkosaurus pushed a commit to krunkosaurus/jquery that referenced this pull request Apr 20, 2011
markelog pushed a commit to markelog/jquery that referenced this pull request Aug 9, 2011
@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants