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

Update step_12.ngdoc #5922

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 50 additions & 37 deletions docs/content/tutorial/step_12.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -340,45 +340,58 @@ Although we could do that, let's take the opportunity to learn how to create Jav

__`app/js/animations.js`.__
<pre>
angular.module('phonecatAnimations', ['ngAnimate'])

.animation('.phone', function() {
return {
addClass : function(element, className, done) {
if(className != 'active') {
return;
}
element.css({
position: 'absolute',
top: 500,
left: 0,
display: 'block'
});
jQuery(element).animate({
top: 0
}, done);

return function(cancel) {
if(cancel) element.stop();
};
},
removeClass : function(element, className, done) {
if(className != 'active') return;
element.css({
position: 'absolute',
left: 0,
top: 0
});
jQuery(element).animate({
top: -500
}, done);

return function(cancel) {
if(cancel) element.stop();
};
var phonecatAnimations = angular.module('phonecatAnimations', ['ngAnimate']);

phonecatAnimations.animation('.phone', function() {

var animateUp = function(element, className, done) {
if(className != 'active') {
return;
}
element.css({
position: 'absolute',
top: 500,
left: 0,
display: 'block'
});

jQuery(element).animate({
top: 0
}, done);

return function(cancel) {
if(cancel) {
element.stop();
}
};
});
}

var animateDown = function(element, className, done) {
if(className != 'active') {
return;
}
element.css({
position: 'absolute',
left: 0,
top: 0
});

jQuery(element).animate({
top: -500
}, done);

return function(cancel) {
if(cancel) {
element.stop();
}
};
}

return {
addClass: animateUp,
removeClass: animateDown
};
});
</pre>

Note that we're using {@link http://jquery.com/ jQuery} to implement the animation. jQuery
Expand Down