Skip to content

Commit

Permalink
Speed up the transition for lengthier slides
Browse files Browse the repository at this point in the history
Sleeping 0.002 works great for slides that don't have a lot of text, but
it tends to take a lot for ones that do. This can get very annoying when
you're moving back and forth between longer slides.
  • Loading branch information
skanev committed Sep 23, 2014
1 parent 0375d74 commit 449e83e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/tkn
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ require 'io/console'
require 'active_support/core_ext/string/strip'
require 'pygments'

TRANSITIONS_TIME = 0.3
MAX_CHAR_DELAY = 0.002

#
# --- DSL -------------------------------------------------------------
Expand Down Expand Up @@ -287,9 +289,12 @@ loop do
if image?(slide)
render(slide)
else
render(slide).each_char do |c|
output = render(slide)
pause = [TRANSITIONS_TIME / output.length, MAX_CHAR_DELAY].min

output.each_char do |c|
print c
sleep 0.002 # old-school touch: running cursor
sleep pause # old-school touch: running cursor
end
end

Expand Down

0 comments on commit 449e83e

Please sign in to comment.