Skip to content

Commit

Permalink
before and after
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgervang committed Jan 2, 2021
1 parent 0f6264c commit 43e9034
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
74 changes: 74 additions & 0 deletions examples/quick-start/quick-start-after.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React from 'react';
import {ScatterplotLayer, TextLayer} from '@deck.gl/layers';
import {QuickAnimation, Keyframes, hold} from 'hubble.gl';
import {easing} from 'popmotion';

const INITIAL_VIEW_STATE = {
longitude: -122.402,
latitude: 37.79,
zoom: 11
};

const DURATION = 3000;

export default function App() {
const getKeyframes = () => {
return {
circle: new Keyframes({
features: ['opacity', 'radiusScale'],
keyframes: [
{opacity: 0, radiusScale: 0.01},
{opacity: 1, radiusScale: 1},
{opacity: 1, radiusScale: 1},
{opacity: 1, radiusScale: 20}
],
timings: [0, 1000, 1500, 3000],
easings: [easing.anticipate, hold, easing.anticipate]
}),
text: new Keyframes({
features: ['opacity', 'getAngle'],
keyframes: [
{opacity: 0, getAngle: -90},
{opacity: 1, getAngle: 0},
{opacity: 1, getAngle: 0},
{opacity: 0, getAngle: 0}
],
timings: [0, 1000, 1500, 2000],
easings: [easing.reversed(easing.anticipate), hold, easing.easeIn]
})
};
};

const getLayers = scene => {
const circleFrame = scene.keyframes.circle.getFrame();
const textFrame = scene.keyframes.text.getFrame();
return [
new ScatterplotLayer({
data: [{position: [-122.402, 37.79], color: [255, 0, 0], radius: 1000}],
getFillColor: d => d.color,
getRadius: d => d.radius,
...circleFrame
}),
new TextLayer({
data: [{position: [-122.402, 37.79], text: 'Hello World'}],
...textFrame
})
];
};

return (
<QuickAnimation
initialViewState={INITIAL_VIEW_STATE}
width={640}
height={480}
getLayers={getLayers}
getLayerKeyframes={getKeyframes}
deckProps={{
parameters: {
clearColor: [255, 255, 255, 1]
}
}}
duration={DURATION}
/>
);
}
34 changes: 34 additions & 0 deletions examples/quick-start/quick-start-before.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import {ScatterplotLayer, TextLayer} from '@deck.gl/layers';
import DeckGL from '@deck.gl/react';

const INITIAL_VIEW_STATE = {
longitude: -122.402,
latitude: 37.79,
zoom: 11
};

export default function App() {
const layers = [
new ScatterplotLayer({
data: [{position: [-122.402, 37.79], color: [255, 0, 0], radius: 1000}],
getFillColor: d => d.color,
getRadius: d => d.radius
}),
new TextLayer({
data: [{position: [-122.402, 37.79], text: 'Hello World'}]
})
];

return (
<DeckGL
initialViewState={INITIAL_VIEW_STATE}
width={640}
height={480}
layers={layers}
parameters={{
clearColor: [255, 255, 255, 1]
}}
/>
);
}

0 comments on commit 43e9034

Please sign in to comment.