Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8864f44
chore: added drag drop area functionality
khanzzirfan Feb 13, 2023
1d476bc
chore: updated version
khanzzirfan Feb 13, 2023
8275f62
chore: updated package names
khanzzirfan Feb 13, 2023
0dff53a
set top 0 style property
khanzzirfan Feb 13, 2023
1fd0c24
early exit if dropped row is same as current row
khanzzirfan Feb 13, 2023
9c73cf6
early exit if dropped row is same as current row
khanzzirfan Feb 13, 2023
7dad377
chore: updated cursor colors
khanzzirfan Feb 18, 2023
1e5ccdc
chore: updated svg
khanzzirfan Feb 18, 2023
85dbf46
feat: fixed the row drag and drop and cursor locked to its y position
khanzzirfan Feb 21, 2023
1b160c5
fix: updated packagejson
khanzzirfan Feb 21, 2023
941743a
fix: updated packagejson
khanzzirfan Feb 21, 2023
629a2c9
fix: updated packagejson
khanzzirfan Feb 21, 2023
b446a19
fix: fixed bug fixes on null action items
khanzzirfan Mar 31, 2023
0b12559
fix: fixed bug fixes on null action items
khanzzirfan Mar 31, 2023
248e9cb
fix: fixed bug fixes on null action items
khanzzirfan Mar 31, 2023
7566dc8
fix: fixed bug fixes on null action items
khanzzirfan Mar 31, 2023
635ce17
fix: fixed bug fixes on null action items
khanzzirfan Apr 1, 2023
6bbb9b4
chore: updated notes/docs
khanzzirfan Apr 1, 2023
6c35191
chore: removed zindex
khanzzirfan Apr 6, 2023
3c7c6a5
chore: updated action items overlapping
khanzzirfan May 19, 2023
66ef1bc
chore: released new version for overlapping the action items
khanzzirfan May 19, 2023
61f29ef
fix:overlap percentage moved down to 0.01
khanzzirfan Jul 8, 2023
ed1522f
fix: updated timeline editor
khanzzirfan Sep 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@
# ide
/.vscode
/.idea

/ .npmrc
.npmrc
646 changes: 646 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

43 changes: 23 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
## Original Work

This repo is forked from the original author repo `@xzdarcy/react-timeline-editor` and modified with custom requirements.

# React Timeline Editor

[![npm version](https://img.shields.io/npm/v/@xzdarcy/react-timeline-editor.svg?style=flat-square)](https://www.npmjs.com/package/@xzdarcy/react-timeline-editor)
[![npm downloads](https://img.shields.io/npm/dm/@xzdarcy/react-timeline-editor.svg?style=flat-square)](https://www.npmjs.com/package/@xzdarcy/react-timeline-editor)

**[React Timeline Editor](https://zdarcy.com/)** is a react component used to quickly build a timeline animation editor.

![example](https://github.com/xzdarcy/react-timeline-editor/blob/f79d85eee8a723e5210c04232daf2c51888418c0/public/assets/timeline.gif)

## Getting Started

```bash
Expand All @@ -15,50 +21,47 @@ npm install @xzdarcy/react-timeline-editor
import { Timeline, TimelineEffect, TimelineRow } from '@xzdarcy/react-timeline-editor';
import React from 'react';

const mockData: TimelineRow[] = [{
id: "0",
const mockData: TimelineRow[] = [
{
id: '0',
actions: [
{
id: "action00",
id: 'action00',
start: 0,
end: 2,
effectId: "effect0",
effectId: 'effect0',
},
],
},
{
id: "1",
id: '1',
actions: [
{
id: "action10",
id: 'action10',
start: 1.5,
end: 5,
effectId: "effect1",
}
effectId: 'effect1',
},
],
}]
},
];

const mockEffect: Record<string, TimelineEffect> = {
effect0: {
id: "effect0",
name: "效果0",
id: 'effect0',
name: '效果0',
},
effect1: {
id: "effect1",
name: "效果1",
id: 'effect1',
name: '效果1',
},
};

const TimelineEditor = () => {
return (
<Timeline
editorData={mockData}
effects={mockEffect}
/>
);
return <Timeline editorData={mockData} effects={mockEffect} />;
};
```

## Documention
Checkout the [Docs](https://zdarcy.com/) for a demonstration of some basic and advanced features.

Checkout the [Docs](https://zdarcy.com/) for a demonstration of some basic and advanced features.
23 changes: 23 additions & 0 deletions docs/editor-demo/editor-basic-irfan/disable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Timeline } from '../../../src/components/timeline';

import { Switch } from 'antd';
import { cloneDeep } from 'lodash';
import React, { useState } from 'react';
import './index.less';
import { mockData, mockEffect } from './mock';

const defaultEditorData = cloneDeep(mockData);

const TimelineEditor = () => {
const [data, setData] = useState(defaultEditorData);
const [allow, setAllow] = useState(true);

return (
<div className="timeline-editor-example0">
<Switch checkedChildren="开启编辑" unCheckedChildren="禁用编辑" checked={allow} onChange={(e) => setAllow(e)} style={{ marginBottom: 20 }} />
<Timeline onChange={setData} editorData={data} effects={mockEffect} disableDrag={!allow} />
</div>
);
};

export default TimelineEditor;
22 changes: 22 additions & 0 deletions docs/editor-demo/editor-basic-irfan/hideCursor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Timeline } from '../../../src/components/timeline';
import { Switch } from 'antd';
import { cloneDeep } from 'lodash';
import React, { useState } from 'react';
import './index.less';
import { mockData, mockEffect } from './mock';

const defaultEditorData = cloneDeep(mockData);

const TimelineEditor = () => {
const [data, setData] = useState(defaultEditorData);
const [showCursor, setShowCursor] = useState(false);

return (
<div className="timeline-editor-example0">
<Switch checkedChildren="开启光标" unCheckedChildren="隐藏光标" checked={showCursor} onChange={(e) => setShowCursor(e)} style={{ marginBottom: 20 }} />
<Timeline onChange={setData} editorData={data} effects={mockEffect} hideCursor={!showCursor} />
</div>
);
};

export default TimelineEditor;
66 changes: 66 additions & 0 deletions docs/editor-demo/editor-basic-irfan/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@import '~antd/dist/antd.css';

.dropzone {
background-color: #bfe4ff;
border: dashed 4px transparent;
border-radius: 4px;
margin: 10px auto 30px;
padding: 10px;
width: 80%;
transition: background-color 0.3s;
}

.drop-active {
border-color: #aaa !important;
}

.collison-active {
background-color: #E0115F !important;
}

.drop-target {
// background-color: #29e !important;
border-color: #fff !important;
border-style: solid;
}

.drag-drop {
display: inline-block;
min-width: 40px;
padding: 2em 0.5em;
margin: 1rem 0 0 1rem;

color: #fff;
// background-color: #29e;
border: solid 2px #fff;

touch-action: none;
transform: translate(0px, 0px);

transition: background-color 0.3s;
}

.drag-drop.can-drop {
color: #000;
background-color: #4e4;
}

.timeline-editor-example0 {
.timeline-editor {
width: 100%;
max-width: 800px;
height: 300px;

.timeline-editor-edit-row:nth-of-type(odd) {
background-color: darkolivegreen;
}

&-action {
height: 28px !important;
top: 50%;
transform: translateY(-50%);
}
}
}


13 changes: 13 additions & 0 deletions docs/editor-demo/editor-basic-irfan/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: editor basic irfan test
toc: 'menu'
order: 0
group:
title: 编辑器示例
---

### dropzone usage

> 尝试向右拖动动作块,可自动识别无限滚动延长

<code src="./index.tsx"></code>
52 changes: 52 additions & 0 deletions docs/editor-demo/editor-basic-irfan/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { cloneDeep } from 'lodash';
import React, { useEffect, useState } from 'react';
import './index.less';
import { mockData, mockEffect } from './mock';
import { Timeline } from '../../../src/components/timeline';

const defaultEditorData = cloneDeep(mockData);

const TimelineEditor = () => {
const [data, setData] = useState(defaultEditorData);

React.useEffect(() => {
console.log('data updated', data);
}, [data]);

const handleOnMoveEnd = (...params) => {
console.log('actionMoveEnd', params);
};

const handleOnResizeEnd = (...params) => {
console.log('handleOnResizeEnd', params);
};

const handleOnClickRow = (...params) => {
console.log('handleOnClickRow', params);
};

const handleOnContextMenuRow = (...params) => {
console.log('handleOnContextMenuRow', params);
};

return (
<div className="timeline-editor-example0">
<Timeline
onChange={setData}
editorData={data}
effects={mockEffect}
hideCursor={false}
autoScroll
autoReRender
onActionMoveEnd={handleOnMoveEnd}
onActionResizeEnd={handleOnResizeEnd}
onClickActionOnly={handleOnClickRow}
onContextMenuAction={handleOnContextMenuRow}
gridSnap
dragLine
/>
</div>
);
};

export default TimelineEditor;
65 changes: 65 additions & 0 deletions docs/editor-demo/editor-basic-irfan/mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { TimelineEffect, TimelineRow } from '@xzdarcy/react-timeline-editor';

export const mockEffect: Record<string, TimelineEffect> = {
effect0: {
id: 'effect0',
name: '效果0',
},
effect1: {
id: 'effect1',
name: '效果1',
},
};

export const mockData: TimelineRow[] = [
{
id: '0',
actions: [
{
id: 'action00',
start: 0,
end: 2,
effectId: 'effect0',
},
],
},
{
id: '1',
actions: [
{
id: 'action10',
start: 1.5,
end: 5,
effectId: 'effect1',
},
],
},
{
id: '2',
actions: [
{
id: 'action20',
start: 3,
end: 4,
effectId: 'effect0',
},
],
},
// {
// id: "3",
// actions: [
// {
// id: "action30",
// start: 4,
// end: 4.5,
// effectId: "effect1",
// },
// {
// id: "action31",
// start: 6,
// end: 8,
// effectId: "effect1",
// },
// ],
// },
];
4 changes: 3 additions & 1 deletion docs/editor-demo/editor-scroll-sync/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Timeline, TimelineState } from '@xzdarcy/react-timeline-editor';
// import { Timeline, TimelineState } from '@xzdarcy/react-timeline-editor';
import { Timeline } from '../../../src/components/timeline';
import { TimelineState } from '../../../src/interface/timeline';
import { cloneDeep } from 'lodash';
import React, { useRef, useState } from 'react';
import './index.less';
Expand Down
12 changes: 6 additions & 6 deletions docs/engine/engine-standalone/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ const TimelineEditor = () => {
timelineEngine.current.on('paused', () => setIsPlaying(false));
timelineEngine.current.on('afterSetTime', ({ time }) => setTime(time));
timelineEngine.current.on('setTimeByTick', ({ time }) => setTime(time));

let dur = 0;
mockData.forEach(row => {
row.actions.forEach(action => dur = Math.max(dur, action.end));
})
mockData.forEach((row) => {
row.actions.forEach((action) => (dur = Math.max(dur, action.end)));
});
setDuration(dur);

return () => {
Expand All @@ -50,7 +50,7 @@ const TimelineEditor = () => {
const handleSetTime = (value: number) => {
timelineEngine.current.setTime(Number(value));
timelineEngine.current.reRender();
}
};

// 时间展示
const timeRender = (time: number) => {
Expand All @@ -69,7 +69,7 @@ const TimelineEditor = () => {
</div>
<div className="play-time">
<div className="play-time-current">{timeRender(time)}</div>
<Slider onChange={handleSetTime} className="play-time-slider" step={0.01} min={0} max={duration} value={time} />
{/* <Slider onChange={handleSetTime} className="play-time-slider" step={0.01} min={0} max={duration} value={time} /> */}
<div className="play-time-duration">{timeRender(duration)}</div>
</div>
</div>
Expand Down
Loading