Animation and transitions
Quick answer
This tutorial shows how deck.gl animates through per-frame property updates rather than a timeline. It covers transitions and updateTriggers on accessors such as getRadius and getFillColor, then drives TripsLayer with currentTime, getPath and getTimestamps inside requestAnimationFrame. It insists on reusing layer instances and calling setProps. Readers can build smooth highlights, pulsing heights and moving vehicle trails.
Key points
- Declare transitions with a duration in milliseconds and bump updateTriggers to restart it.
- Animate TripsLayer by changing only currentTime; keep path and timestamps arrays unchanged.
- Call layer.setProps inside the frame loop instead of constructing a new layer each frame.
Example
var selected = 'BJ-001';
function buildStations(activeId) {
return new deck.ScatterplotLayer({
id: 'stations',
data: stations,
getPosition: function (d) { return [d.lng, d.lat]; },
getRadius: function (d) { return d.id === activeId ? 16 : 7; },
getFillColor: function (d) {
return d.id === activeId ? [255, 180, 0, 240] : [40, 140, 255, 200];
},
transitions: {
getRadius: 600,
getFillColor: 600
},
updateTriggers: {
getRadius: activeId,
getFillColor: activeId
}
});
}
var first = buildStations(selected);var tripData = [
{
vendor: 1,
path: [
[116.20, 39.80, 0], [116.30, 39.88, 0], [116.41, 39.91, 0],
[116.52, 39.96, 0], [116.60, 40.02, 0]
],
timestamps: [0, 40, 90, 140, 200]
},
{
vendor: 2,
path: [
[116.35, 40.05, 0], [116.38, 39.96, 0], [116.44, 39.90, 0], [116.50, 39.86, 0]
],
timestamps: [0, 60, 120, 190]
}
];
var tripsLayer = new deck.TripsLayer({
id: 'trips',
data: tripData,
getPath: function (d) { return d.path; },
getTimestamps: function (d) { return d.timestamps; },
getColor: function (d) { return d.vendor === 1 ? [255, 180, 0] : [0, 180, 255]; },
widthMinPixels: 3,
trailLength: 30,
currentTime: 0
});
Notes
- transitions only interpolate accessor values, not opacity or elevationScale.
- Mixed time units across paths leave some trips permanently invisible.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). Animation and transitions. https://www.jingweizhi.com/en/deckgl/tutorials/animation.html (accessed 2026-11-03).