-
-
Notifications
You must be signed in to change notification settings - Fork 311
feat: Decouple properties in timeline animations & support parallel animation #814
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
base: dev
Are you sure you want to change the base?
Changes from 3 commits
f99e5ed
6235704
07a61d1
650fcfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,6 +10,8 @@ import { SCREEN_CONSTANTS } from '@/Core/util/constants'; | |||||||||
| import { logger } from '@/Core/util/logger'; | ||||||||||
| import { v4 as uuid } from 'uuid'; | ||||||||||
| import { cloneDeep, isEqual } from 'lodash'; | ||||||||||
| import omitBy from 'lodash/omitBy'; | ||||||||||
| import isUndefined from 'lodash/isUndefined'; | ||||||||||
| import * as PIXI from 'pixi.js'; | ||||||||||
| import { INSTALLED } from 'pixi.js'; | ||||||||||
| import { GifResource } from './GifResource'; | ||||||||||
|
|
@@ -71,9 +73,9 @@ export default class PixiStage { | |||||||||
| if (!source) return; | ||||||||||
| const targetScale = target.scale; | ||||||||||
| const targetPosition = target.position; | ||||||||||
| if (target.scale) Object.assign(targetScale, source.scale); | ||||||||||
| if (target.position) Object.assign(targetPosition, source.position); | ||||||||||
| Object.assign(target, source); | ||||||||||
| if (target.scale) Object.assign(targetScale!, omitBy(source.scale,isUndefined)); | ||||||||||
| if (target.position) Object.assign(targetPosition!, omitBy(source.position,isUndefined)); | ||||||||||
|
||||||||||
| if (target.scale) Object.assign(targetScale!, omitBy(source.scale,isUndefined)); | |
| if (target.position) Object.assign(targetPosition!, omitBy(source.position,isUndefined)); | |
| if (target.scale) Object.assign(targetScale!, omitBy(source.scale || {},isUndefined)); | |
| if (target.position) Object.assign(targetPosition!, omitBy(source.position || {},isUndefined)); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||||||||||||||||||
| import { AnimationFrame } from '@/Core/Modules/animations'; | ||||||||||||||||||||||||
| import { webgalStore } from '@/store/store'; | ||||||||||||||||||||||||
| import { has, pickBy } from 'lodash'; | ||||||||||||||||||||||||
| import isNull from 'lodash/isNull'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| type AnimationObj = Array<AnimationFrame>; | ||||||||||||||||||||||||
|
|
@@ -10,6 +11,7 @@ export function generateTransformAnimationObj( | |||||||||||||||||||||||
| applyFrame: AnimationFrame, | ||||||||||||||||||||||||
| duration: number | string | boolean | null, | ||||||||||||||||||||||||
| ease: string, | ||||||||||||||||||||||||
| writeFullEffect: boolean = true, | ||||||||||||||||||||||||
| ): AnimationObj { | ||||||||||||||||||||||||
| let animationObj; | ||||||||||||||||||||||||
| // 获取那个 target 的当前变换 | ||||||||||||||||||||||||
|
|
@@ -25,8 +27,18 @@ export function generateTransformAnimationObj( | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // 找到 effect | ||||||||||||||||||||||||
| if (targetEffect) { | ||||||||||||||||||||||||
| const effectWithDuration = { ...targetEffect!.transform!, duration: 0, ease }; | ||||||||||||||||||||||||
| animationObj.unshift(effectWithDuration); | ||||||||||||||||||||||||
| if (writeFullEffect) { | ||||||||||||||||||||||||
| const effectWithDuration = { ...targetEffect!.transform!, duration: 0, ease }; | ||||||||||||||||||||||||
| animationObj.unshift(effectWithDuration); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| else { | ||||||||||||||||||||||||
| const targetScale = pickBy(targetEffect!.transform!.scale, (source, key)=> has(applyFrame.scale, key)) | ||||||||||||||||||||||||
| const targetPosition = pickBy(targetEffect!.transform!.position, (source, key)=> has(applyFrame.position, key)) | ||||||||||||||||||||||||
| const effectWithDuration = { ...pickBy(targetEffect!.transform!, (source, key)=> has(applyFrame, key) ), duration: 0, ease }; | ||||||||||||||||||||||||
| effectWithDuration.scale = targetScale | ||||||||||||||||||||||||
| effectWithDuration.position = targetPosition | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| const targetScale = pickBy(targetEffect!.transform!.scale, (source, key)=> has(applyFrame.scale, key)) | |
| const targetPosition = pickBy(targetEffect!.transform!.position, (source, key)=> has(applyFrame.position, key)) | |
| const effectWithDuration = { ...pickBy(targetEffect!.transform!, (source, key)=> has(applyFrame, key) ), duration: 0, ease }; | |
| effectWithDuration.scale = targetScale | |
| effectWithDuration.position = targetPosition | |
| const currentTransform = targetEffect?.transform || {}; | |
| const targetScale = pickBy(currentTransform.scale || {}, (source, key)=> has(applyFrame.scale || {}, key)); | |
| const targetPosition = pickBy(currentTransform.position || {}, (source, key)=> has(applyFrame.position || {}, key)); | |
| const effectWithDuration = { ...pickBy(currentTransform, (source, key)=> has(applyFrame, key) ), duration: 0, ease }; | |
| effectWithDuration.scale = targetScale; | |
| effectWithDuration.position = targetPosition; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The properties
scaleandpositionontargetSetEffect.transformare optional and can beundefined. CallingpickBywithundefinedas the first argument will cause a runtime error.You should provide a fallback empty object to
pickByto prevent this.