Skip to main content

Bug Tracker

Side navigation

#8498 closed feature (fixed)

Opened March 10, 2011 10:05PM UTC

Closed December 09, 2011 01:07AM UTC

Last modified March 09, 2012 04:18PM UTC

Animate Hooks

Reported by: gnarf Owned by: gnarf
Priority: blocker Milestone: 1.7.2
Component: effects Version: 1.5.1
Keywords: Cc: scottgonzalez
Blocked by: Blocking:
Description

A quick fiddle to demonstrate: http://jsfiddle.net/gnarf/9muvX/

I propose that we should add a pre-filter to the properties animated in

.animate()
that would allow us to convert

a call like

.animate({margin: 40})
into
.animate({marginLeft: 40, marginRight: 40, marginBottom: 40, marginTop: 40}) 
automatically.

Attachments (0)
Change History (19)

Changed March 10, 2011 10:29PM UTC by scottgonzalez comment:1

cc: → scott.gonzalez

Changed March 14, 2011 02:45PM UTC by rwaldron comment:2

component: unfiledeffects
priority: undecidedlow
status: newopen

Changed March 14, 2011 02:45PM UTC by rwaldron comment:3

owner: → gnarf
status: openassigned

Changed April 17, 2011 05:11PM UTC by john comment:4

summary: Animating the "margin" "padding" or other similar properties can cause bad "flashes"Animate Hooks
type: bugfeature

I'm mutating this bug into a new feature request - where we add in a set of hooks for doing animations.

Changed May 22, 2011 07:27PM UTC by john comment:5

keywords: → 1.7-discuss

Nominating ticket for 1.7 discussion.

Changed May 22, 2011 09:30PM UTC by rwaldron comment:6

description: A quick fiddle to demonstrate: http://jsfiddle.net/gnarf/9muvX/ \ \ I propose that we should add a pre-filter to the properties animated in {{{.animate()}}} that would allow us to convert \ a call like {{{.animate({margin: 40})}}} into {{{.animate({marginLeft: 40, marginRight: 40, marginBottom: 40, marginTop: 40}) }}} automatically. \ A quick fiddle to demonstrate: http://jsfiddle.net/gnarf/9muvX/\ \ I propose that we should add a pre-filter to the properties animated in {{{.animate()}}} that would allow us to convert\ a call like {{{.animate({margin: 40})}}} into {{{.animate({marginLeft: 40, marginRight: 40, marginBottom: 40, marginTop: 40}) }}} automatically.\

+1, In support of, pending #9401

Changed May 23, 2011 12:33AM UTC by jaubourg comment:7

-1, sounds reasonable to me... but wouldn't making cssHooks more "open" (that is being able to return the redefinition if needed by a third-party like effects.js) solve the issue? I hate the idea of css related stuff hidden into effects.js.

Changed May 23, 2011 12:38AM UTC by gnarf comment:8

_comment0: well Julian - Yeah, I kinda agree that the {{{animateHooks}}} might not be the best implementation -- likely we could make it like: \ \ {{{ \ $.cssHooks.margin = { \ map: function( value ) { \ return { \ marginLeft: value, //....etc.... \ }; \ }; \ }}} \ And then soup up .css and .animate to read from the hooks looking for a "map" when they are doing their property mangling stuff i.e. camelCase. \ \ My reasoning for taking the approach is that when you do {{{ .css("margin", 10); }}} you could actually skip "mapping" the values, because the browser already does it for you, there isn't a ton of reason to have the "map" unless you are doing a per-property based animation.... \ \ Does the other approach get a more favorable vote in your eyes?1306111175258437
_comment1: well Julian - Yeah, I kinda agree that the {{{animateHooks}}} might not be the best implementation -- likely we could make it like: \ \ {{{ \ $.cssHooks.margin = { \ map: function( value ) { \ return { \ marginLeft: value, \ marginRight: value, \ marginTop: value, \ marginBottom: value, \ }; \ } \ }; \ }}} \ And then soup up .css and .animate to read from the hooks looking for a "map" when they are doing their property mangling stuff i.e. camelCase. \ \ My reasoning for taking the approach is that when you do {{{ .css("margin", 10); }}} you could actually skip "mapping" the values, because the browser already does it for you, there isn't a ton of reason to have the "map" unless you are doing a per-property based animation.... \ \ Does the other approach get a more favorable vote in your eyes?1306111203994241
_comment2: well Julian - Yeah, I kinda agree that the {{{animateHooks}}} might not be the best implementation -- likely we could make it like: \ \ {{{ \ $.cssHooks.margin = { \ map: function( value ) { \ return { \ marginLeft: value, \ marginRight: value, \ marginTop: value, \ marginBottom: value, \ }; \ } \ }; \ }}} \ And then soup up .css and .animate to read from the hooks looking for a "map" when they are doing their property mangling stuff i.e. camelCase. \ \ My reasoning for taking the approach I did is that when you do {{{ .css("margin", 10); }}} you could actually skip "mapping" the values, because the browser already does it for you, there isn't a ton of reason to have the "map" unless you are doing a per-property based animation.... \ \ Does the other approach get a more favorable vote in your eyes?1306111240056985
description: A quick fiddle to demonstrate: http://jsfiddle.net/gnarf/9muvX/\ \ I propose that we should add a pre-filter to the properties animated in {{{.animate()}}} that would allow us to convert\ a call like {{{.animate({margin: 40})}}} into {{{.animate({marginLeft: 40, marginRight: 40, marginBottom: 40, marginTop: 40}) }}} automatically.\ A quick fiddle to demonstrate: http://jsfiddle.net/gnarf/9muvX/ \ \ I propose that we should add a pre-filter to the properties animated in {{{.animate()}}} that would allow us to convert \ a call like {{{.animate({margin: 40})}}} into {{{.animate({marginLeft: 40, marginRight: 40, marginBottom: 40, marginTop: 40}) }}} automatically. \

well Julian - Yeah, I kinda agree that the

animateHooks
might not be the best implementation -- likely we could make it like:

$.cssHooks.margin = {
    map: function( value ) {
        return {
            marginLeft: value,
            marginRight: value,
            marginTop: value,
            marginBottom: value
        }; 
    }
};

And then soup up .css and .animate to read from the hooks looking for a "map" when they are doing their property mangling stuff i.e. camelCase.

My reasoning for taking the approach I did is that when you do

 .css("margin", 10); 
you could actually skip "mapping" the values, because the browser already does it for you, there isn't a ton of reason to have the "map" unless you are doing a per-property based animation....

Does the other approach get a more favorable vote in your eyes?

Changed May 23, 2011 04:22AM UTC by timmywil comment:9

description: A quick fiddle to demonstrate: http://jsfiddle.net/gnarf/9muvX/ \ \ I propose that we should add a pre-filter to the properties animated in {{{.animate()}}} that would allow us to convert \ a call like {{{.animate({margin: 40})}}} into {{{.animate({marginLeft: 40, marginRight: 40, marginBottom: 40, marginTop: 40}) }}} automatically. \ A quick fiddle to demonstrate: http://jsfiddle.net/gnarf/9muvX/\ \ I propose that we should add a pre-filter to the properties animated in {{{.animate()}}} that would allow us to convert\ a call like {{{.animate({margin: 40})}}} into {{{.animate({marginLeft: 40, marginRight: 40, marginBottom: 40, marginTop: 40}) }}} automatically.\

+1, Yes, I think some stuff should be in effects.js

Changed May 24, 2011 09:18PM UTC by dmethvin comment:10

description: A quick fiddle to demonstrate: http://jsfiddle.net/gnarf/9muvX/\ \ I propose that we should add a pre-filter to the properties animated in {{{.animate()}}} that would allow us to convert\ a call like {{{.animate({margin: 40})}}} into {{{.animate({marginLeft: 40, marginRight: 40, marginBottom: 40, marginTop: 40}) }}} automatically.\ A quick fiddle to demonstrate: http://jsfiddle.net/gnarf/9muvX/ \ \ I propose that we should add a pre-filter to the properties animated in {{{.animate()}}} that would allow us to convert \ a call like {{{.animate({margin: 40})}}} into {{{.animate({marginLeft: 40, marginRight: 40, marginBottom: 40, marginTop: 40}) }}} automatically. \

-1, I have concerns about size if all these strings are going into the source -- is there some other solution? Maybe a plugin would be best for non-trivial animation enhancements.

Changed June 03, 2011 01:49PM UTC by john comment:11

description: A quick fiddle to demonstrate: http://jsfiddle.net/gnarf/9muvX/ \ \ I propose that we should add a pre-filter to the properties animated in {{{.animate()}}} that would allow us to convert \ a call like {{{.animate({margin: 40})}}} into {{{.animate({marginLeft: 40, marginRight: 40, marginBottom: 40, marginTop: 40}) }}} automatically. \ A quick fiddle to demonstrate: http://jsfiddle.net/gnarf/9muvX/\ \ I propose that we should add a pre-filter to the properties animated in {{{.animate()}}} that would allow us to convert\ a call like {{{.animate({margin: 40})}}} into {{{.animate({marginLeft: 40, marginRight: 40, marginBottom: 40, marginTop: 40}) }}} automatically.\

+1, Only if we're talking about adding a map to cssHooks (and not necessarily adding in those properties ourselves).

Changed June 04, 2011 10:16PM UTC by addyosmani comment:12

+1

Changed June 05, 2011 09:22PM UTC by ajpiano comment:13

description: A quick fiddle to demonstrate: http://jsfiddle.net/gnarf/9muvX/\ \ I propose that we should add a pre-filter to the properties animated in {{{.animate()}}} that would allow us to convert\ a call like {{{.animate({margin: 40})}}} into {{{.animate({marginLeft: 40, marginRight: 40, marginBottom: 40, marginTop: 40}) }}} automatically.\ A quick fiddle to demonstrate: http://jsfiddle.net/gnarf/9muvX/ \ \ I propose that we should add a pre-filter to the properties animated in {{{.animate()}}} that would allow us to convert \ a call like {{{.animate({margin: 40})}}} into {{{.animate({marginLeft: 40, marginRight: 40, marginBottom: 40, marginTop: 40}) }}} automatically. \

+1, I like the idea of just using cssHooks from within .animate

Changed June 07, 2011 11:32PM UTC by timmywil comment:14

If we are looking towards supporting animations like margin: 30px 40px, I've worked out a regex for it for fun:

/(-?\\d+)(?:px)?(?:\\s+(-?\\d+)(?:px)?)?(?:\\s+(-?\\d+)(?:px)?)?(?:\\s+(-?\\d+)(?:px)?)?/

xoxo

Changed July 12, 2011 03:02PM UTC by dmethvin comment:15

milestone: 1.next1.7
priority: lowblocker

Changed September 18, 2011 08:24AM UTC by gnarf comment:16

Changed October 10, 2011 04:17PM UTC by gnarf comment:17

keywords: 1.7-discuss1.8-discuss
milestone: 1.71.8

Changed December 09, 2011 01:07AM UTC by Mike Sherov comment:18

resolution: → fixed
status: assignedclosed

Fix #8498. Add cssHooks[prop].expand for use by animate().

Changeset: 8f5f1b2e6c0f7b8b6d66bfc06c7b169a9443c2b8

Changed December 10, 2011 06:40PM UTC by dmethvin comment:19

keywords: 1.8-discuss
milestone: 1.81.7.2