diff options
author | andrewdkim <adkim414@gmail.com> | 2019-07-17 16:52:53 -0400 |
---|---|---|
committer | andrewdkim <adkim414@gmail.com> | 2019-07-17 16:52:53 -0400 |
commit | 5517ece90ee87d34acfa456435c162c32f2a6637 (patch) | |
tree | 2af6fef46108f0e59bb3c424dbd4b72346cab40d /src/client/views/nodes/Keyframe.tsx | |
parent | 7ec4c97da1b6b410117ac675aff81d3a9a16593a (diff) |
video integration and bug fixes
Diffstat (limited to 'src/client/views/nodes/Keyframe.tsx')
-rw-r--r-- | src/client/views/nodes/Keyframe.tsx | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/src/client/views/nodes/Keyframe.tsx b/src/client/views/nodes/Keyframe.tsx index 3f8197c8c..81cbd274d 100644 --- a/src/client/views/nodes/Keyframe.tsx +++ b/src/client/views/nodes/Keyframe.tsx @@ -92,6 +92,33 @@ export class Keyframe extends React.Component<IProps> { } + @computed + private get firstKeyframe(){ + let first: (Doc | undefined) = undefined; + DocListCast(this.regiondata.keyframes!).forEach(kf => { + if (kf.type !== KeyframeFunc.KeyframeType.fade){ + if (!first || first && NumCast(kf.time) < NumCast(first.time)){ + first = kf; + } + } + }); + return first; + } + + @computed + private get lastKeyframe(){ + let last: (Doc | undefined) = undefined; + DocListCast(this.regiondata.keyframes!).forEach(kf => { + if (kf.type !== KeyframeFunc.KeyframeType.fade){ + if (!last || last && NumCast(kf.time) > NumCast(last.time)){ + last = kf; + } + } + }); + return last; + } + + componentWillMount(){ if (!this.regiondata.keyframes){ this.regiondata.keyframes = new List<Doc>(); @@ -134,21 +161,17 @@ export class Keyframe extends React.Component<IProps> { @action makeKeyData = (kfpos: number, type:KeyframeFunc.KeyframeType = KeyframeFunc.KeyframeType.default) => { //Kfpos is mouse offsetX, representing time - let hasData = false; - this.regiondata.keyframes!.forEach(TK => { //TK is TimeAndKey - TK = TK as Doc; + DocListCast(this.regiondata.keyframes!).forEach(TK => { //TK is TimeAndKey if (TK.time === kfpos) { - hasData = true; + return TK; } }); - if (!hasData) { - let TK: Doc = new Doc(); - TK.time = kfpos; - TK.key = Doc.MakeCopy(this.props.node, true); - TK.type = type; - this.regiondata.keyframes!.push(TK); - return TK; - } + let TK: Doc = new Doc(); + TK.time = kfpos; + TK.key = Doc.MakeCopy(this.props.node, true); + TK.type = type; + this.regiondata.keyframes!.push(TK); + return TK; } @action @@ -218,18 +241,19 @@ export class Keyframe extends React.Component<IProps> { let bar = this._bar.current!; let barX = bar.getBoundingClientRect().left; let offset = e.clientX - barX; - if (this.regiondata.duration - offset < this.regiondata.fadeIn + this.regiondata.fadeOut){ + let firstkf: (Doc | undefined) = this.firstKeyframe; + console.log(offset); + if (firstkf && this.regiondata.position + this.regiondata.fadeIn + offset>= NumCast(firstkf!.time)) { + this.regiondata.position = NumCast(firstkf!.time) - this.regiondata.fadeIn; + + }else if (this.regiondata.duration - offset < this.regiondata.fadeIn + this.regiondata.fadeOut){ // no keyframes, just fades this.regiondata.position -= (this.regiondata.fadeIn + this.regiondata.fadeOut - this.regiondata.duration); this.regiondata.duration = this.regiondata.fadeIn + this.regiondata.fadeOut; } else { this.regiondata.duration -= offset; this.regiondata.position += offset; } - // for (let i = 0; i < this.regiondata.keyframes!.length; i++){ - // console.log((this.regiondata.keyframes![i] as Doc).time); - // (this.regiondata.keyframes![i] as Doc).time = NumCast((this.regiondata.keyframes![i] as Doc).time) - offset; - // console.log((this.regiondata.keyframes![i] as Doc).time); - // } + } @@ -245,7 +269,7 @@ export class Keyframe extends React.Component<IProps> { }else { this.regiondata.duration += offset; } - } + } createDivider = (type?: KeyframeFunc.Direction): JSX.Element => { if (type === "left") { |