Jump to content

Can you suing POstScript to make an animation?

Featured Replies

Did you abandon your previous thread?

I'm assuming (not "suing"!) you mean JavaScript not POstScript here, too.

JavaScript has no sleep. The idea of blocking code in something built for the UI is an anathema. However, you can fake it.

The following works. It wraps the setTimeout in a promise, then uses await to block on it.

<html>
<head><title>Not a great general purpose programming environment</title></head>
<body>
<script>
ShowLine("You can't always get what you want.");

function sleep(ms = 0) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function ShowLine(input) {
  for (let i = 0; i < input.length; i++) {
    await sleep(250);
    document.write(input[i]);
  };
}
</script>
</body>
</html>

 

It seems to me you're really needing something else to do your programming with. (But you don't provide much detail to work with.)

 

Create an account or sign in to comment

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.