Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

$animate#enter logic does not totally make sense #6275

Closed
caitp opened this issue Feb 15, 2014 · 1 comment
Closed

$animate#enter logic does not totally make sense #6275

caitp opened this issue Feb 15, 2014 · 1 comment

Comments

@caitp
Copy link
Contributor

caitp commented Feb 15, 2014

      enter: function(element, parent, after, done) {
        if (after) {
          after.after(element);
        } else {
          if (!parent || !parent[0]) {
            /* caitp note: `after` is falsy here, what are we doing? */
            parent = after.parent();
          }
          /* caitp note: I feel like if `after` is null, the expected behaviour would be
             to prepend. I'm sure there's a precedent for this somewhere, but I
             can't seem to find it on MDN. But someone on IRC was asking about
             how to make $animate#enter() prepend rather than append. */
          parent.append(element);
        }
        done && $timeout(done, 0, false);
      },

note I did sort of post this before doing a proper investigation to see how broken this is, but I'll do a quick test and close this if I think the behaviour is acceptable.

Oh, the IRC user posted an issue re: this too, #6274. Anyways, taking a quick look

http://plnkr.co/edit/qECZ0VMVLCMDugY9Usat?p=preview (quick example which demonstrates the TypeError)

http://plnkr.co/edit/8gUgr5uqFhOV9nmquzQB?p=preview (quick example showing the sort of unexpected behaviour) --- I'm not totally sure if this is a huge problem, but it seems that people want to be able to prepend

@Foxandxss
Copy link
Member

I would like to prepend also. I am creating a factory/directive which pop up some alert boxes. Since it is a rewriting from an jQuery plugin and it supports both prepend and append, I would love to be able to stack the alerts in the other way (prepend).

matsko added a commit to matsko/angular.js that referenced this issue Apr 1, 2014
…nstead of at the end

BREAKING CHANGE: $animate will no longer place elements at the end of the parent container
when enter or move is used with a parent container element. Any former directives that rely
on this feature must be slightly modified to work around this fix. The same effect can be achieved
by finding the final element in the parent container list and using that as the after element
(which is the 3rd argument in the enter and move $animate operations).

Closes angular#4934
Closes angular#6275
matsko added a commit to matsko/angular.js that referenced this issue Apr 1, 2014
…nstead of at the end

$animate.enter and $animate.move both insert the element at the end of the provided parent
container element. If an after element is provided then they will place the inserted element
after that one. This works fine, but there is no way to place an item at the top of the provided
parent container using both these functions. This commit fixes this issue.

BREAKING CHANGE: $animate will no longer place elements at the end of the parent container
when enter or move is used with a parent container element. Any former directives that rely
on this feature must be slightly modified to work around this fix. The same effect can be achieved
by finding the final element in the parent container list and using that as the after element
(which is the 3rd argument in the enter and move $animate operations).

Closes angular#4934
Closes angular#6275
matsko added a commit to matsko/angular.js that referenced this issue Apr 3, 2014
…nstead of at the end

With 1.2.x, $animate.enter and $animate.move both insert the element at the end of the provided
parent container element when only the parent element is provided. If an after element is provided
then they will place the inserted element after that one. This works fine, but there is no way to
place an item at the top of the provided parent container using both these functions.

Closes angular#4934
Closes angular#6275

BREAKING CHANGE: $animate will no longer default the after parameter to the last element of the parent
container. Instead, when after is not specified, the new element will be inserted as the first child of
the parent container.

To update existing code change any instances of $animate.enter() or $animate.move() from:

$animate.enter(element, parent);

to:

$animate.enter(element, parent, angular.element(parent[0].lastChild));
matsko added a commit to matsko/angular.js that referenced this issue Apr 3, 2014
…nstead of at the end

With 1.2.x, $animate.enter and $animate.move both insert the element at the end of the provided
parent container element when only the parent element is provided. If an after element is provided
then they will place the inserted element after that one. This works fine, but there is no way to
place an item at the top of the provided parent container using both these functions.

Closes angular#4934
Closes angular#6275

BREAKING CHANGE: $animate will no longer default the after parameter to the last element of the parent
container. Instead, when after is not specified, the new element will be inserted as the first child of
the parent container.

To update existing code change any instances of $animate.enter() or $animate.move() from:

`$animate.enter(element, parent);`

to:

`$animate.enter(element, parent, angular.element(parent[0].lastChild));`
@matsko matsko closed this as completed in 1cb8584 Apr 3, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants