File: 0.html

package info (click to toggle)
node-q 1.5.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 624 kB
  • sloc: javascript: 6,612; makefile: 7
file content (36 lines) | stat: -rw-r--r-- 989 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE html>
<html>
<head>
    <title>Q.async animation example</title>
    <!--
        Works in browsers that support ES6 geneartors, like Chromium 29 with
        the --harmony flag.

        Peter Hallam, Tom van Cutsem, Mark S. Miller, Dave Herman, Andy Wingo.
        The animation example was taken from
        <http://wiki.ecmascript.org/doku.php?id=strawman:deferred_functions>
    -->
</head>
<body>
    <div id="box" style="width: 20px; height: 20px; background-color: red;"></div>

    <script src="../../q.js"></script>
    <script>
    (function () {
        "use strict";

        var deferredAnimate = Q.async(function* (element) {
            for (var i = 0; i < 100; ++i) {
                element.style.marginLeft = i + "px";
                yield Q.delay(20);
            }
        });

        Q.spawn(function* () {
            yield deferredAnimate(document.getElementById("box"));
            alert("Done!");
        });
    }());
    </script>
</body>
</html>