Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anyone facing issue when updating the data outside the timeline context #66

Open
surinderlohat opened this issue Mar 2, 2025 · 0 comments

Comments

@surinderlohat
Copy link

I am working on a task in which i have to update the data from outside the timeline

when this editor data is changed outside then it shows error Invalid offset NaN specified

const editorData = useMemo(() => updatedTracks(timeline.data), [timeline.data]);

import { useMemo } from 'react';
import { Timeline } from '@xzdarcy/react-timeline-editor';
import { TimelineControls } from './TimelineControls/TimelineControls';
import { startLeft, useTimeLine } from '../TimelineContext/TimelineContext';
import { updatedTracks } from './fields';
import { AudioRender } from './CustomElements/AudioRender';
import { VideoRender } from './CustomElements/RenderVideo';
import './Timeline.less';

const TimelineComponent = () => {
  const { timelineRef, selectedSegment, scaleWidth, ...timeline } = useTimeLine();
  const editorData = useMemo(() => updatedTracks(timeline.data), [timeline.data]);

  const mockEffect = {
    effect0: {
      id: 'effect0',
      name: '效果0',
    },
  };

  return (
    <div style={{ height: '150px', position: 'relative', width: '100%' }}>
      <TimelineControls />
      <Timeline
        ref={timelineRef as any}
        editorData={editorData}
        autoScroll={true}
        effects={mockEffect}
        onChange={() => {}}
        onClickAction={(ev, a) => timeline.setSelectedSegment(a.action)}
        scaleSplitCount={10}
        scaleWidth={scaleWidth}
        startLeft={startLeft}
        getActionRender={(action, row) => {
          if (row.id === '1') {
            return <VideoRender action={action} row={row} />;
          }

          if (row.id === '2') {
            return <AudioRender action={action} row={row} />;
          }
        }}
        style={{ width: '100%' }}
      />
    </div>
  );
};

export default TimelineComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant