Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #30633

Re: Animated vector field...

From "Chris M. Thomasson" <nospam@nospam.no>
Newsgroups comp.lang.javascript
Subject Re: Animated vector field...
Date 2016-06-05 14:13 -0700
Organization Aioe.org NNTP Server
Message-ID <nj24lg$13n0$1@gioia.aioe.org> (permalink)
References <nitnvj$mko$1@gioia.aioe.org> <nito4t$mo7$1@gioia.aioe.org> <1650761.fOrR8oP7AL@PointedEars.de>

Show all headers | View raw


> > Chris M. Thomasson wrote:

> > I forgot to mention that it will not work if your browser does not have
> > (requestAnimationFrame). I do not have a workaround function for this as
> > of yet.  :^o

> "Thomas 'PointedEars' Lahn" wrote:
> Several of us have been doing rather smooth animations with
> window.setTimeout() since the beginning of the previous decade.
> One pattern is:

I am thinking of using:
___________________________________________________
// Request animation workaround
var g_request_animation_frame = window.requestAnimationFrame;

function prv_request_animation_frame(cb) {
    if (!g_request_animation_frame) {
        g_request_animation_frame =
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame ||
            window.oRequestAnimationFrame ||
            window.msRequestAnimationFrame;

        if (! g_request_animation_frame) {
            var last_time = 0;

            g_request_animation_frame = function (callback) {
                var cur_time = new Date().getTime();
                var time_addend = Math.max(0, 16 - (cur_time - last_time));

                var id = window.setTimeout(function () {
                    callback(cur_time + time_addend);
                }, time_addend);

                last_time = cur_time + time_addend;

                return id;
            };
        }
    }

    g_request_animation_frame(cb);
}
___________________________________________________


It's working on older devices like my SONY Bravia TV. It's a
bit slow on these devices, but that's because I am plotting a
lot of points per-frame. I am going to tune this up, and have
it flying Cell phones, and older TV's.

It should be ready tonight or tommorrow morning. 

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Animated vector field... "Chris M. Thomasson" <nospam@nospam.no> - 2016-06-03 22:12 -0700
  Re: Animated vector field... "Chris M. Thomasson" <nospam@nospam.no> - 2016-06-03 22:15 -0700
    Re: Animated vector field... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-04 13:45 +0200
      Re: Animated vector field... "Chris M. Thomasson" <nospam@nospam.no> - 2016-06-05 14:13 -0700
        Re: Animated vector field... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-05 21:33 -0700
        Re: Animated vector field... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-06 21:55 +0200
  Re: Animated vector field... Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2016-06-04 10:47 +0100
    Re: Animated vector field... "Chris M. Thomasson" <nospam@nospam.no> - 2016-06-05 14:16 -0700
  Re: Animated vector field... chris.m.thomasson.1@gmail.com - 2016-06-05 21:37 -0700
  Re: Animated vector field... "Chris M. Thomasson" <nospam@nospam.com> - 2016-06-09 16:02 -0700

csiph-web