Visual effects (fading)
This commit is contained in:
parent
664580b36a
commit
6bd79aa2d4
|
@ -2,11 +2,19 @@ inkjs = require("inkjs")
|
||||||
|
|
||||||
continueToNextChoice = (s) ->
|
continueToNextChoice = (s) ->
|
||||||
while (s.canContinue)
|
while (s.canContinue)
|
||||||
$("#content").append("<p>#{s.Continue()}</p>")
|
paragraphs = s.Continue().split("\n")
|
||||||
|
delay = 1000
|
||||||
|
for i in paragraphs
|
||||||
|
if i != ""
|
||||||
|
html = $.parseHTML(i)
|
||||||
|
$("#content").append($('<p>').hide().html(html).fadeIn(delay))
|
||||||
|
delay += 500
|
||||||
|
scrollTo = $('#options').offset().top
|
||||||
if (s.currentChoices.length > 0)
|
if (s.currentChoices.length > 0)
|
||||||
$("#options").html("")
|
$("#options").html("").hide()
|
||||||
for choice in s.currentChoices
|
for choice in s.currentChoices
|
||||||
$("#options").append("<li><a href='#' id='choice-#{choice.index}' data-index=#{choice.index}>#{choice.text}</a></li>")
|
$("#options").append("<li><a href='#' id='choice-#{choice.index}' data-index=#{choice.index}>#{choice.text}</a></li>")
|
||||||
|
$("#options").fadeIn(800)
|
||||||
$("#options li a").click(() ->
|
$("#options li a").click(() ->
|
||||||
s.ChooseChoiceIndex($(this).data("index"))
|
s.ChooseChoiceIndex($(this).data("index"))
|
||||||
continueToNextChoice(s)
|
continueToNextChoice(s)
|
||||||
|
@ -15,6 +23,9 @@ continueToNextChoice = (s) ->
|
||||||
else
|
else
|
||||||
$("#content").append("<p>THE END</p>")
|
$("#content").append("<p>THE END</p>")
|
||||||
$("#options").html("")
|
$("#options").html("")
|
||||||
|
$('html, body').animate({
|
||||||
|
scrollTop: scrollTo
|
||||||
|
}, 800)
|
||||||
|
|
||||||
fetch('fogg.ink.json')
|
fetch('fogg.ink.json')
|
||||||
.then((response) ->
|
.then((response) ->
|
||||||
|
|
Loading…
Reference in a new issue