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

bugfix: #1772

Merged
merged 12 commits into from
Jan 3, 2025
36 changes: 18 additions & 18 deletions packages/webpack-plugin/lib/platform/style/wx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,11 @@ module.exports = function getSpec ({ warn, error }) {
// transform 转换
const formatTransform = ({ prop, value, selector }, { mode }) => {
// css var & 数组直接返回
if (Array.isArray(value) || calcExp.test(value)) return { prop, value }
if (Array.isArray(value) || cssVariableExp.test(value)) return { prop, value }
const values = parseValues(value)
const transform = []
values.forEach(item => {
const match = item.match(/([/\w]+)\(([^)]+)\)/)
const match = item.match(/([/\w]+)\((.+)\)/)
if (match && match.length >= 3) {
let key = match[1]
const val = match[2]
Expand Down Expand Up @@ -407,23 +407,23 @@ module.exports = function getSpec ({ warn, error }) {
case 'rotate3d': // x y z angle
case 'translate3d': // x y 支持 z不支持
case 'scale3d': // x y 支持 z不支持
{
// 2 个以上的值处理
key = key.replace('3d', '')
const vals = parseValues(val, ',').splice(0, key === 'rotate' ? 4 : 3)
// scale(.5) === scaleX(.5) scaleY(.5)
if (vals.length === 1 && key === 'scale') {
vals.push(vals[0])
}
const xyz = ['X', 'Y', 'Z']
transform.push(...vals.map((v, index) => {
if (key !== 'rotate' && index > 1) {
unsupportedPropError({ prop: `${key}Z`, value, selector }, { mode })
}
return { [`${key}${xyz[index] || ''}`]: v.trim() }
}))
break
{
// 2 个以上的值处理
key = key.replace('3d', '')
const vals = parseValues(val, ',').splice(0, key === 'rotate' ? 4 : 3)
// scale(.5) === scaleX(.5) scaleY(.5)
if (vals.length === 1 && key === 'scale') {
vals.push(vals[0])
}
const xyz = ['X', 'Y', 'Z']
Copy link
Collaborator

Choose a reason for hiding this comment

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

这块为啥会有diff

transform.push(...vals.map((v, index) => {
if (key !== 'rotate' && index > 1) {
unsupportedPropError({ prop: `${key}Z`, value, selector }, { mode })
}
return { [`${key}${xyz[index] || ''}`]: v.trim() }
}))
break
}
case 'translateZ':
case 'scaleZ':
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const parseTransform = (transformStr: string) => {
const values = parseValues(transformStr)
const transform: {[propName: string]: string|number|number[]}[] = []
values.forEach(item => {
const match = item.match(/([/\w]+)\(([^)]+)\)/)
const match = item.match(/([/\w]+)\((.+)\)/)
if (match && match.length >= 3) {
let key = match[1]
const val = match[2]
Expand Down Expand Up @@ -240,14 +240,13 @@ export default function useAnimationHooks<T, P> (props: _ViewProps) {
}
// 添加每个key的多次step动画
animatedKeys.forEach(key => {
const ruleV = isTransform(key) ? transform.get(key) : rules.get(key)
// key不存在,第一轮取shareValMap[key]value,非第一轮取上一轮的
const toVal = rules.get(key) !== undefined
? rules.get(key)
: transform.get(key) !== undefined
? transform.get(key)
: index > 0
? lastValueMap[key]
: shareValMap[key].value
const toVal = ruleV !== undefined
? ruleV
: index > 0
? lastValueMap[key]
: shareValMap[key].value
const animation = getAnimation({ key, value: toVal! }, { delay, duration, easing }, needSetCallback ? setTransformOrigin : undefined)
needSetCallback = false
if (!sequence[key]) {
Expand Down
Loading