Skip to content

支持 transition-duration delay easing等动态设置#2457

Open
wenwenhua wants to merge 17 commits into
masterfrom
fix-transform-order
Open

支持 transition-duration delay easing等动态设置#2457
wenwenhua wants to merge 17 commits into
masterfrom
fix-transform-order

Conversation

@wenwenhua
Copy link
Copy Markdown
Collaborator

No description provided.

// 记录上次style map
// const lastStyleRef = useRef({} as {[propName: keyof ExtendedViewStyle]: number|string})
// ** 从 style 中获取动画数据
const transitionMap = useMemo(() => {
Copy link
Copy Markdown
Collaborator

@hiyuki hiyuki Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const transitionMapVersion = useMemo(()=>{  
  const changed = compare()
  return changed ? newVersion : oldVersion 
}, [originalStyle])

const transitionMap = useMemo(() => {...}, [transitionMapVersion])

const hasChanged = transitionKeys.some(key => prevStyle[key] !== originalStyle[key])
if (hasChanged) {
transitionKeys.forEach(key => { lastTransitionStyleRef.current[key] = originalStyle[key] })
transitionMapVersionRef.current++
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接返回个new Symbol就行,不需要用这个ref自增

const prevStyle = lastTransitionStyleRef.current
const hasChanged = transitionKeys.some(key => prevStyle[key] !== originalStyle[key])
if (hasChanged) {
transitionKeys.forEach(key => { lastTransitionStyleRef.current[key] = originalStyle[key] })
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

比较和更新这两事情不能放一个循环里解决么

const transitionMap = useMemo(() => {
return parseTransitionStyle(originalStyle)
}, [])
const newTransitionMap = parseTransitionStyle(originalStyle)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这堆逻辑到底在干嘛?为啥需要这么复杂?

return newTransitionMap
}
// 检测 transitionProperty 是否变化
if (newPropertyKeys !== initialPropertyKeysRef.current) {
Copy link
Copy Markdown
Collaborator

@hiyuki hiyuki May 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个检测不能再上面做么,你上面本来也在遍历比较属性

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

Successfully merging this pull request may close these issues.

2 participants