Mbonea commited on
Commit
ce7cdca
·
1 Parent(s): 7845886

stable interpolation archieved

Browse files
Remotion-app/src/HelloWorld/ImageStream.jsx CHANGED
@@ -13,7 +13,6 @@ import {slide} from '@remotion/transitions/slide';
13
  export default function ImageStream() {
14
  const {fps} = useVideoConfig();
15
 
16
- const frame = useCurrentFrame();
17
  return (
18
  <AbsoluteFill
19
  style={{
@@ -30,22 +29,6 @@ export default function ImageStream() {
30
  >
31
  <TransitionSeries>
32
  {imageSequences.map((entry, index) => {
33
- const durationInFrames = (entry.end - entry.start) * fps;
34
-
35
- const zoom = interpolate(
36
- frame,
37
- [
38
- fps * entry.start,
39
- fps * entry.start + durationInFrames / 2,
40
- fps * entry.end,
41
- ],
42
- [1, 1.5, 1.3],
43
- {
44
- extrapolateLeft: 'clamp',
45
- extrapolateRight: 'clamp',
46
- }
47
- );
48
-
49
  return (
50
  <>
51
  <TransitionSeries.Sequence
@@ -53,12 +36,7 @@ export default function ImageStream() {
53
  // from={fps * entry.start}
54
  durationInFrames={fps * (entry.end - entry.start)}
55
  >
56
- <Img
57
- style={{
58
- transform: `scale(${zoom})`,
59
- }}
60
- src={staticFile(entry.name)}
61
- />
62
  </TransitionSeries.Sequence>
63
  <TransitionSeries.Transition
64
  presentation={slide('from-left')}
@@ -74,3 +52,38 @@ export default function ImageStream() {
74
  </AbsoluteFill>
75
  );
76
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  export default function ImageStream() {
14
  const {fps} = useVideoConfig();
15
 
 
16
  return (
17
  <AbsoluteFill
18
  style={{
 
29
  >
30
  <TransitionSeries>
31
  {imageSequences.map((entry, index) => {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  return (
33
  <>
34
  <TransitionSeries.Sequence
 
36
  // from={fps * entry.start}
37
  durationInFrames={fps * (entry.end - entry.start)}
38
  >
39
+ <Images key={index} entry={entry} />;
 
 
 
 
 
40
  </TransitionSeries.Sequence>
41
  <TransitionSeries.Transition
42
  presentation={slide('from-left')}
 
52
  </AbsoluteFill>
53
  );
54
  }
55
+
56
+ const Images = ({entry, key}) => {
57
+ const {fps} = useVideoConfig();
58
+ const frame = useCurrentFrame();
59
+ const durationInFrames = (entry.end - entry.start) * fps;
60
+ const spr = spring({
61
+ fps,
62
+ frame,
63
+ config: {
64
+ damping: 100,
65
+ },
66
+ delay: 0,
67
+ from: 0,
68
+ to: 1,
69
+ durationInFrames: durationInFrames,
70
+ });
71
+
72
+ const zoom = interpolate(spr, [0, 0.5, 1], [1, 1.5, 1.3], {
73
+ // easing: Easing.bezier(0.8, 0.22, 0.96, 0.65),
74
+ extrapolateLeft: 'clamp',
75
+ extrapolateRight: 'clamp',
76
+ });
77
+
78
+ return (
79
+ <>
80
+ <Img
81
+ style={{
82
+ transform: `scale(${zoom})`,
83
+ // transition: 'all 5s ease',
84
+ }}
85
+ src={staticFile(entry.name)}
86
+ />
87
+ </>
88
+ );
89
+ };