GithubHelp home page GithubHelp logo

Slow down animation? about aerisjs HOT 2 CLOSED

andrewlively avatar andrewlively commented on September 4, 2024
Slow down animation?

from aerisjs.

Comments (2)

eschwartz avatar eschwartz commented on September 4, 2024

Yes -- adjusting the animation speed is simple:

var animation = new aeris.interactive.animations.AnimationSync([radarLayer], {
  // set the initial animation speed
  speed: 60
});

// Change the animation speed
animation.setSpeed(120);

The speed number represents how many minutes of weather data will be displayed in a second. So for example, a speed of 60 means that your animation will play from 1pm to 2pm in one second.

By the way, the animations are set up so you can "lazy-load" tiles images, without making the user wait for everything to load. The tile images are loaded in such a way that you can immediately start the animation, without waiting for everything to preload -- it will start out "choppy", but become smoother as images are loaded.

v0.7.13 introduced a preload method, which makes this even easier. To make the UI feel less laggy, I'll do something like this:

// Start preloading animation images
myAnimation.preload();

// Show some kind of loading indicator
showLoadingProgressUI('0% complete');

// Hide the animation layer until the animation is preloaded
// Note that the radar layer MUST have a map set when you call preload()
radarLayer.setMap(null);

// Animation objects fire 'load:progress' events as
// tile images are loaded.
myAnimation.on('load:progress', function(progress) {
  var progressDisplay = (progress * 100).toFixed(0)  + '% complete';
  showLoadingProgressUI(progressDisplay);

  // Because preloading the entire animation may take a while,
  // we'll just tell the user that we're done when enough images are loaded
  // that animation won't look choppy
  if (progress > 0.5) {
    // Hide your loading UI
    hideLoadingProgressUI();

    // clean up the 'load:progress' event listener
    myAnimation.off('load:progress');

    // Show the radar layer
    radarLayer.setMap(myMap);
  }
});

I'm a little embarrassed to say that none of this is really well documented. If you're interested, there's some auto-generated documentation up at docs.aerisjs.com/api.

I hope this helps -- let me know if you run into any issues.

Edan

from aerisjs.

andrewlively avatar andrewlively commented on September 4, 2024

Awesome, I figured you had something in there, I just had trouble finding it. Thanks for the help and the link, I'll bookmark that as a reference

from aerisjs.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.