-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(animation): Implement simple Slide animation
- Loading branch information
0 parents
commit 7d20621
Showing
12 changed files
with
317 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015-node4"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
node_modules | ||
|
||
# Babel compiled sources | ||
lib | ||
|
||
# Miscellaneous | ||
*~ | ||
*# | ||
.DS_STORE | ||
.netbeans | ||
nbproject | ||
.idea | ||
.node_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Automatically ignored per: | ||
# https://www.npmjs.org/doc/developers.html#Keeping-files-out-of-your-package | ||
# | ||
# .*.swp | ||
# ._* | ||
# .DS_Store | ||
# .git | ||
# .hg | ||
# .lock-wscript | ||
# .svn | ||
# .wafpickle-* | ||
# CVS | ||
# npm-debug.log | ||
# node_modules | ||
|
||
*.seed | ||
*.log | ||
*.csv | ||
*.dat | ||
*.out | ||
*.pid | ||
*.gz | ||
*.orig | ||
|
||
work | ||
build | ||
examples | ||
src | ||
test | ||
pids | ||
logs | ||
results | ||
coverage | ||
lib-cov | ||
html-report | ||
xunit.xml | ||
|
||
.project | ||
.idea | ||
.settings | ||
.iml | ||
*.sublime-workspace | ||
*.sublime-project | ||
|
||
ehthumbs.db | ||
Icon? | ||
Thumbs.db | ||
.AppleDouble | ||
.LSOverride | ||
.Spotlight-V100 | ||
.Trashes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
sudo: false | ||
language: node_js | ||
cache: | ||
directories: | ||
- node_modules | ||
notifications: | ||
email: true | ||
node_js: | ||
- stable | ||
- 5 | ||
- 4 | ||
before_script: | ||
- npm prune | ||
after_success: | ||
- 'curl -Lo travis_after_all.py https://git.io/travis_after_all' | ||
- python travis_after_all.py | ||
- 'export $(cat .to_export_back) &> /dev/null' | ||
- npm run coveralls | ||
- npm run semantic-release | ||
branches: | ||
except: | ||
- "/^v\\d+\\.\\d+\\.\\d+$/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Eugene Obrezkov | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# kittik-animation-slide | ||
|
||
![Build Status](https://img.shields.io/travis/kittikjs/animation-slide.svg) | ||
![Coverage](https://img.shields.io/coveralls/kittikjs/animation-slide.svg) | ||
|
||
![Downloads](https://img.shields.io/npm/dm/kittik-animation-slide.svg) | ||
![Downloads](https://img.shields.io/npm/dt/kittik-animation-slide.svg) | ||
![npm version](https://img.shields.io/npm/v/kittik-animation-slide.svg) | ||
![License](https://img.shields.io/npm/l/kittik-animation-slide.svg) | ||
|
||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) | ||
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
![dependencies](https://img.shields.io/david/kittikjs/animation-slide.svg) | ||
![dev dependencies](https://img.shields.io/david/dev/kittikjs/animation-slide.svg) | ||
|
||
Slide animation for Kittik shapes | ||
|
||
## Getting Started | ||
|
||
Install it via npm: | ||
|
||
```shell | ||
npm install kittik-animation-slide | ||
``` | ||
|
||
Include in your project: | ||
|
||
```javascript | ||
import Slide from 'kittik-animation-slide'; | ||
import Rectangle from 'kittik-shape-rectangle'; | ||
import { Cursor } from 'kittik-cursor'; | ||
|
||
const cursor = Cursor.create(); | ||
const shape = Rectangle.create(); | ||
|
||
Slide.create().animate(shape, cursor).then(shape => doSmthNextWithShape(shape)); | ||
``` | ||
|
||
## License | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Eugene Obrezkov | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"use strict"; | ||
|
||
const cursor = require('kittik-cursor').Cursor.create().resetTTY(); | ||
const Slide = require('../lib/Slide').default; | ||
const shape = require('kittik-shape-rectangle').default.create({ | ||
text: 'Good news, everybody!', | ||
x: 'center', | ||
background: 'white', | ||
width: '50%' | ||
}); | ||
|
||
new Slide({ | ||
easing: 'inOutSine', | ||
duration: 2000 | ||
}).on('tick', shape => shape.render(cursor) && cursor.flush().eraseScreen()).animate(shape); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "kittik-animation-slide", | ||
"version": "0.0.0-semantic-release", | ||
"description": "Slide animation for Kittik shapes", | ||
"main": "lib/Slide.js", | ||
"bugs": { | ||
"url": "https://github.com/kittikjs/animation-slide/issues" | ||
}, | ||
"homepage": "https://github.com/kittikjs/animation-slide#readme", | ||
"author": "ghaiklor", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/kittikjs/animation-slide.git" | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
"clean": "rm -rf ./lib", | ||
"compile": "npm run clean; babel src --out-dir lib", | ||
"coveralls": "cat ./coverage/lcov.info | coveralls", | ||
"prepublish": "npm run compile", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post", | ||
"test": "babel-node ./node_modules/.bin/isparta cover _mocha" | ||
}, | ||
"dependencies": { | ||
"kittik-animation-basic": "2.0.2" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "6.4.0", | ||
"babel-preset-es2015-node4": "2.0.2", | ||
"chai": "3.4.1", | ||
"coveralls": "2.11.6", | ||
"cz-conventional-changelog": "1.1.5", | ||
"isparta": "4.0.0", | ||
"kittik-cursor": "2.3.1", | ||
"kittik-shape-rectangle": "1.1.1", | ||
"mocha": "2.3.4", | ||
"semantic-release": "4.3.5", | ||
"sinon": "1.17.2" | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
}, | ||
"publishConfig": { | ||
"tag": "latest" | ||
}, | ||
"release": { | ||
"branch": "master" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Animation from 'kittik-animation-basic'; | ||
|
||
/** | ||
* Slide animation that animates sliding of the shapes. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
export default class Slide extends Animation { | ||
/** | ||
* Main method that calls when shape need to be animated. | ||
* | ||
* @override | ||
* @param {Shape} shape | ||
* @param {Cursor} cursor | ||
*/ | ||
animate(shape, cursor) { | ||
return new Promise(resolve => { | ||
return Promise.all([ | ||
this.animateProperty({shape: shape, property: 'x', startValue: 1, endValue: shape.getX()}), | ||
this.animateProperty({shape: shape, property: 'y', startValue: 1, endValue: shape.getY()}) | ||
]).then(shape => resolve(shape)); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
./test/unit/**/*.test.js | ||
--reporter spec | ||
--recursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { assert } from 'chai'; | ||
import sinon from 'sinon'; | ||
import Rectangle from 'kittik-shape-rectangle'; | ||
import Slide from '../../src/Slide'; | ||
|
||
describe('Animation::Slide', () => { | ||
it('Should properly call the animate() method', done => { | ||
let animation = new Slide(); | ||
let shape = new Rectangle(); | ||
let mock = sinon.mock(animation); | ||
|
||
mock.expects('animateProperty').twice().returns(Promise.resolve()); | ||
|
||
animation.animate(shape).then(() => { | ||
mock.verify(); | ||
done(); | ||
}); | ||
}); | ||
}); |