Skip to content

Commit

Permalink
docs(animation): Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaiklor committed Mar 28, 2016
1 parent acbe444 commit 7263750
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
27 changes: 14 additions & 13 deletions examples/advanced.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
"use strict";

const cursor = require('kittik-cursor').create().resetTTY().hideCursor();
const cursor = require('kittik-cursor').create().reset().hideCursor();
const Rectangle = require('kittik-shape-rectangle');
const Slide = require('../lib/Slide');
const AVAILABLE_DIRECTIONS = ['inUp', 'inDown', 'inLeft', 'inRight'];
const shapes = [
Rectangle.create({background: 'dark_blue', x: 'left', y: 'top', text: 'Shape 1'}),
Rectangle.create({background: 'dark_blue', x: 'center', y: 'top', text: 'Shape 2'}),
Rectangle.create({background: 'dark_blue', x: 'right', y: 'top', text: 'Shape 3'}),
Rectangle.create({background: 'navy_blue', x: 'left', y: 'middle', text: 'Shape 4'}),
Rectangle.create({background: 'navy_blue', x: 'center', y: 'middle', text: 'Shape 5'}),
Rectangle.create({background: 'navy_blue', x: 'right', y: 'middle', text: 'Shape 6'}),
Rectangle.create({background: 'yellow_1', x: 'left', y: 'bottom', text: 'Shape 7'}),
Rectangle.create({background: 'yellow_1', x: 'center', y: 'bottom', text: 'Shape 8'}),
Rectangle.create({background: 'yellow_1', x: 'right', y: 'bottom', text: 'Shape 9'})
Rectangle.create(cursor, {background: 'dark_blue', x: 'left', y: 'top', text: 'Shape 1'}),
Rectangle.create(cursor, {background: 'dark_blue', x: 'center', y: 'top', text: 'Shape 2'}),
Rectangle.create(cursor, {background: 'dark_blue', x: 'right', y: 'top', text: 'Shape 3'}),
Rectangle.create(cursor, {background: 'navy_blue', x: 'left', y: 'middle', text: 'Shape 4'}),
Rectangle.create(cursor, {background: 'navy_blue', x: 'center', y: 'middle', text: 'Shape 5'}),
Rectangle.create(cursor, {background: 'navy_blue', x: 'right', y: 'middle', text: 'Shape 6'}),
Rectangle.create(cursor, {background: 'yellow', x: 'left', y: 'bottom', text: 'Shape 7'}),
Rectangle.create(cursor, {background: 'yellow', x: 'center', y: 'bottom', text: 'Shape 8'}),
Rectangle.create(cursor, {background: 'yellow', x: 'right', y: 'bottom', text: 'Shape 9'})
];

// It's implemented in Kittik engine, so you need just to implement child class from Animation as above
let renderedShapes = [];
let currentShapeIndex = 0;

const onTick = (shape, property, value) => {
renderedShapes.forEach(shape => shape.render(cursor));
shape.render(cursor);
cursor.flush().eraseScreen();
cursor.eraseScreen();
renderedShapes.forEach(shape => shape.render());
shape.render();
cursor.flush();
};

const nextShape = shape => {
Expand Down
6 changes: 3 additions & 3 deletions examples/simple.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use strict";

const cursor = require('kittik-cursor').create().resetTTY().hideCursor();
const cursor = require('kittik-cursor').create().reset().hideCursor();
const Slide = require('../lib/Slide');
const shape = require('kittik-shape-rectangle').create({
const shape = require('kittik-shape-rectangle').create(cursor, {
text: 'Good news, everybody!',
x: 'center',
background: 'white',
foreground: 'black',
width: '50%'
});

new Slide({duration: 3000}).on('tick', shape => shape.render(cursor) && cursor.flush().eraseScreen()).animate(shape).then(() => cursor.showCursor().flush());
new Slide({duration: 3000}).on('tick', shape => cursor.eraseScreen() && shape.render() && cursor.flush()).animate(shape).then(() => cursor.showCursor());

0 comments on commit 7263750

Please sign in to comment.