Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/initial velocity directives #1

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 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
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,59 @@
[![Build Status](https://travis-ci.org/thisissoon/angular-velocity.svg?branch=develop)](https://travis-ci.org/thisissoon/angular-velocity)
[![Coverage Status](https://coveralls.io/repos/thisissoon/angular-velocity/badge.svg)](https://coveralls.io/r/thisissoon/angular-velocity)

These velocity directives configure velocity.js keyframe animations on an element.

```
bower install angular-velocity-animate
bower install velocity
```

## Basic Usage:

```html

<!-- add "sn-velocty" directive to the animation target element -->
<div sn-velocity data-keyframes="[{'properties': { opacity: 0 }, 'options': { duration: 1000 }},{'properties': { opacity: 1 },'options': { duration: 1000 }}]">
...
</div>

```
The `data-keyframes` attribute takes an array of velocity.js animation keyframes. See the [Velocity Docs](http://julian.com/research/velocity/#propertiesMap) for available properties and options.


## Animation Groups:

The `sn-velocity-group` directive can be used to animate a number of elements together.

```html

<!-- wrap the target elements with the "sn-velocty-group" directive -->
<sn-velocity-group data-keyframes="animationKeyframes">
<div id="#elem1"></div>
<div id="#elem2"></div>
</sn-velocity-group>

```
The `data-keyframes` attribute of `sn-velocity-group` takes an object of element identifiers. Each key in the object should hold an array of velocity.js animation keyframes as per the `sn-velocity` directive.

```json

{
"#elem1": [{
"properties": { "opacity": "1" },
"options": { "duration": "1000", "loop": true }
}],
"#elem2": [{
"properties": { "left": "+=100" },
"options": { "duration": "1000" }
},{
"properties": { "opacity": "-=100" },
"options": { "duration": "1000" }
}]
}

```

This project structure is based on the [angular-seed](https://github.com/angular/angular-seed) application skeleton for a typical [AngularJS](http://angularjs.org/) web app.

The project is preconfigured to install the Angular framework and a bunch of development and testing tools for instant web development gratification.
Expand Down
28 changes: 28 additions & 0 deletions app/js/directives/snVelocity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"use strict";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to use namespace for filenames you can just call the files velocity.js and velocity-group.js

http://stackoverflow.com/questions/7273316/what-is-the-javascript-filename-naming-convention

/**
* Angular wrapper for velocityjs
* @author SOON_
* @module sn.velocity.snVelocity
* @class snVelocity
* @example <sn-velocity data-keyframes="[{'properties': { opacity: 0 }, 'options': { duration: 1000 }},{'properties': { opacity: 1 },'options': { duration: 1000 }}]"></sn-velocity>
*/
angular.module("sn.velocity.snVelocity", []).directive("snVelocity",[
/**
* @constructor
*/
function() {
return {
restrict: "A",
scope: {
"keyframes": "="
},
link: function($scope, $element){

angular.forEach($scope.keyframes, function(value){
Velocity($element, value.properties, value.options);
});

}
}
}
]);
43 changes: 43 additions & 0 deletions app/js/directives/snVelocityGroup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"use strict";
/**
* @author SOON_
* @module sn.velocity.snVelocityGroup
* @class snVelocityGroup
* @example <sn-velocity-group data-keyframes=""></sn-velocity-group>
*/
angular.module("sn.velocity.snVelocityGroup", [
"sn.velocity.snVelocity"
])

.directive("snVelocityGroup",[
"$compile",
"$rootScope",
/**
* @constructor
*
* @param {Service} $compile angular template compiler
* @param {Object} $rootScope
*/
function($compile, $rootScope) {
return {
restrict: "E",
scope: {
"keyframes": "="
},
link: function($scope, $element){

angular.forEach($scope.keyframes, function(keyframes, key){
var animateElement = angular.element($element[0].querySelector(key));
var scope = $rootScope.$new();
scope.keyframes = keyframes;

animateElement.attr("sn-velocity", "");
animateElement.attr("data-keyframes", "keyframes");

$compile(animateElement)(scope);
});

}
}
}
]);
11 changes: 11 additions & 0 deletions app/js/sn.velocity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use strict";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here you could just use app.js or angular-velocity.js

/**
* Angular wrapper for velocityjs animation library
* @requires velocityjs {@link https://github.com/julianshapiro/velocity}
* @module sn.velocity
* @author SOON_
*/
angular.module("sn.velocity", [
"sn.velocity.snVelocity",
"sn.velocity.snVelocityGroup"
])
8 changes: 0 additions & 8 deletions app/js/soon-example/app.js

This file was deleted.

33 changes: 0 additions & 33 deletions app/js/soon-example/config.js

This file was deleted.

27 changes: 0 additions & 27 deletions app/js/soon-example/controllers/ResultsCtrl.js

This file was deleted.

41 changes: 0 additions & 41 deletions app/js/soon-example/controllers/SearchCtrl.js

This file was deleted.

30 changes: 0 additions & 30 deletions tests/unit/soon-example/controllers/ResultsCtrl.js

This file was deleted.

44 changes: 0 additions & 44 deletions tests/unit/soon-example/controllers/SearchCtrl.js

This file was deleted.