0

I have a system in place that retrieves dynamically retrieves stored messages from the server, the view for it is:

<div id= "messages" data-ng-controller="MessageController">
    <div class="message" data-ng-repeat="message in messages | orderBy:'timestamp':true" data-ng-animate="'animate-message'" >
            <div class="user">
                {{ message.user.username }}
            </div>
            <div class="title">
                {{ message.title }}
            </div>
            <div class="content" data-ng-bind-html-unsafe="message.content">
                {{ message.content }}
            </div>
    </div>
</div>

I then have in my CSS file:

.animate-message-enter {
    transition: 1s linear all;
    -moz-transition: 1s linear all;
    -webkit-transition: 1s linear all;
    -o-transition: 1s linear all;
    -ms-transition: 1s linear all;
    opacity:0;
    position:relative;
    left:-100%;
}

.animate-message-enter.animate-message-enter-active {
    opacity:1;
    left:0%;
}

(this is just an extreme example transition so I can see the transition working)

However, upon a new object being entered into the array via $scope.messages.push(response); the new message simply pops onto the page and no animations take place, does anyone know what I've messed up?

Thanks :)

4
  • 1
    the syntax for transition shorthand should be all 1s linear if i remember correctly. Try fixing that and let me if it works. Commented Jul 10, 2013 at 19:15
  • No change. Still the same instant pop in. Thanks anyway though :) Commented Jul 10, 2013 at 19:26
  • 1
    css looks fine. could be your orderBy - take it out and see what happens. Commented Jul 10, 2013 at 19:47
  • Ahh.. seems I hadn't updated the file that loaded angular to use the latest version instead of the stable version which didn't have the animations. However now I'm only occasionally getting animations appearing.. Commented Jul 10, 2013 at 20:07

1 Answer 1

1

Tried to copy paste your code into plnkr and it works fine. Do you have more code?

http://plnkr.co/edit/gi6h3adNMfoXkUdiN4lY

The only thing I added was a simple addMessage function to test the transition.

<button ng-click="addMessage()">Add Message</button>
Sign up to request clarification or add additional context in comments.

3 Comments

Odd, for me only sometimes does the item on that page transition in.. On Firefox 22.0 / Windows 7
I tried Firefox and got the same problem (was using Chrome Canary before)
Well thank you anyway, proved the error was my fault. Working fine on my site now in chrome. :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.