|
| 1 | +<script>{ |
| 2 | + "title": "Color Animation", |
| 3 | + "excerpt": "Animate colors using .animate().", |
| 4 | + "termSlugs": { |
| 5 | + "category": [ "effects", "effects-core" ] |
| 6 | + } |
| 7 | +}</script> |
| 8 | + |
| 9 | +jQuery UI effects core adds the ability to animate color properties using `rgb()`, |
| 10 | +`rgba()`, hex values, or even color names such as `"aqua"`. Simply include the |
| 11 | +jQuery UI effects core file and [`.animate()`](http://api.jquery.com/animate/) |
| 12 | +will gain support for colors. |
| 13 | + |
| 14 | +The following properties are supported: |
| 15 | + |
| 16 | +* `backgroundColor` |
| 17 | +* `borderBottomColor` |
| 18 | +* `borderLeftColor` |
| 19 | +* `borderRightColor` |
| 20 | +* `borderTopColor` |
| 21 | +* `color` |
| 22 | +* `columnRuleColor` |
| 23 | +* `outlineColor` |
| 24 | +* `textDecorationColor` |
| 25 | +* `textEmphasisColor` |
| 26 | + |
| 27 | +Support for color animation comes from the |
| 28 | +[jQuery Color plugin](https://github.com/jquery/jquery-color). The Color plugin |
| 29 | +provides several functions for working with colors. For full documentation, please |
| 30 | +see the [jQuery Color documentation](https://github.com/jquery/jquery-color#readme). |
| 31 | + |
| 32 | +## Class Animations |
| 33 | + |
| 34 | +While there are use cases for directly animating individual color properties, it |
| 35 | +is often a better approach to contain the styles in a class. jQuery UI provides |
| 36 | +a few methods which will animate the addition or removal of a CSS class, |
| 37 | +specifically [`.addClass()`](/addClass/), [`.removeClass()`](/removeClass/), |
| 38 | +[`.toggleClass()`](/toggleClass/), and [`.switchClass()`](/switchClass/). These |
| 39 | +methods will automatically determine which properties need to change and apply |
| 40 | +the appropriate animations. |
| 41 | + |
| 42 | +## Example |
| 43 | + |
| 44 | +```html |
| 45 | +@partial(resources/color-animation.html) |
| 46 | +``` |
| 47 | + |
| 48 | +<iframe src="/resources/color-animation.html" width="100%" height="200"></iframe> |
0 commit comments