Skip to content

Commit

Permalink
Fixing animation playing in reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharghate committed Sep 23, 2016
1 parent 7fbb6e9 commit e30b65f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store

# Logs
logs
*.log
Expand Down Expand Up @@ -25,4 +27,4 @@ build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
bower_components
bower_components
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-simple-sprite",
"version": "1.0.0",
"version": "1.1.0",
"authors": [
"Tushar Ghate <[email protected]>"
],
Expand Down
42 changes: 21 additions & 21 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,48 @@
<body ng-controller="AppController as appController">
<div>
<h3>Basic Example</h3>
<simple-sprite
src="./images/alien-jump.png"
frame-width="100"
frame-height="155"
frames="8"
repeat="true"
<simple-sprite
src="./images/alien-jump.png"
frame-width="100"
frame-height="155"
frames="8"
repeat="true"
speed="50">
</simple-sprite>
</div>

<div>
<h3>Using frames-per-row</h3>
<simple-sprite
src="./images/alien-jump-rows.png"
frame-width="100"
frame-height="155"
frames="8"
<simple-sprite
src="./images/alien-jump-rows.png"
frame-width="100"
frame-height="155"
frames="8"
frames-per-row="4"
repeat="true"
repeat="true"
speed="50">
</simple-sprite>
</div>

<div>
<h3>Non-Repeating</h3>
<simple-sprite
src="./images/alien-rocket.png"
frame-width="150"
frame-height="348"
frames="3"
repeat="false"
<simple-sprite
src="./images/alien-rocket.png"
frame-width="150"
frame-height="348"
frames="3"
repeat="false"
speed="100">
</simple-sprite>
</div>
</body>

<script type="text/javascript" src="../bower_components/angular/angular.min.js"></script>
<script type="text/javascript" src="../dist/angular-simple-sprite.min.js"></script>
<script type="text/javascript" src="../dist/angular-simple-sprite.js"></script>
<script type="text/javascript">
(function() {
angular
.module('my-app', ['simple-sprite'])
.module('my-app', ['simple-sprite'])
.controller('AppController', AppController)

function AppController() {
Expand Down
8 changes: 4 additions & 4 deletions dist/angular-simple-sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
};

/**
* Initializes the sprite with default CSS styles and options passed in by
* the user. Starts the sprite animation.
* Initializes the sprite with default CSS styles and options passed in by
* the user. Starts the sprite animation.
*/
function init() {
src = $scope.src;
Expand Down Expand Up @@ -67,7 +67,7 @@
function animate() {

/**
* Returns whether the sprite animation has completed or not.
* Returns whether the sprite animation has completed or not.
*/
function isAnimationComplete() {
var toReturn = false;
Expand All @@ -91,7 +91,7 @@

animationInterval = $window.setInterval(function() {
// Update the sprite frame
element.css("background-position", spritePosition.x + "px" + " " + spritePosition.y + "px");
element.css("background-position", -spritePosition.x + "px" + " " + spritePosition.y + "px");

// Determine if we should loop the animation, or stop, if the animation is complete
if (isAnimationComplete()) {
Expand Down
1 change: 0 additions & 1 deletion dist/angular-simple-sprite.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-simple-sprite",
"version": "0.0.0",
"version": "1.0",
"description": "An Angular directive for creating simple sprites.",
"main": "GruntFile.js",
"dependencies": {
Expand Down

0 comments on commit e30b65f

Please sign in to comment.