Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Commit

Permalink
Support page index :octocat:
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyguitar committed Sep 3, 2016
1 parent 8afd84a commit d6b9544
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,10 @@ Slide.prototype.render = function(screen) {
.then(contents => {
/* put parse result into blessed box */
var boxes =[];
var numPages = contents.length;
contents.forEach((content, idx) => {
boxes.push(function(screen) {
boxes.push(function(screen, currPage) {
/* slide content page box */
var box = blessed.box({ top: 'center'
, left: 'center'
, width: '95%'
Expand All @@ -349,14 +351,26 @@ Slide.prototype.render = function(screen) {
, style: {invisible: true}
, content: content});
screen.append(box);
/* slide page index box */
var idxBox = blessed.box({ right: 5
, bottom: 2
, width: "6%"
, height: "5%"
, style: {invisible: true}
, content: currPage + 1 + '/' + numPages});
screen.append(idxBox);

/* set fade in animate */
/* FIXME: current solution is bad */
setTimeout(() => {
box.style.invisible = false;
box.style.transparent = true;
idxBox.style.invisible = false;
idxBox.style.transparent = true;
screen.render();
setTimeout(() => {
box.style.transparent = false;
idxBox.style.transparent = false;
screen.render();
}, 80);
}, 100);
Expand Down

0 comments on commit d6b9544

Please sign in to comment.