forked from mbk-lab/rui_orig
2
0
Fork 0

Optimisation

This commit is contained in:
Alexei Anoshenko 2022-08-11 19:18:36 +03:00
parent 38a8fd2920
commit 9a5fd64758
1 changed files with 25 additions and 21 deletions

View File

@ -493,22 +493,19 @@ func (animation *animationData) writeTransitionString(tag string, buffer *string
func (animation *animationData) timingFunctionCSS(session Session) string { func (animation *animationData) timingFunctionCSS(session Session) string {
if timingFunction, ok := stringProperty(animation, TimingFunction, session); ok { if timingFunction, ok := stringProperty(animation, TimingFunction, session); ok {
if timingFunction, ok = session.resolveConstants(timingFunction); ok && IsTimingFunctionValid(timingFunction, session) { if timingFunction, ok = session.resolveConstants(timingFunction); ok && isTimingFunctionValid(timingFunction) {
return timingFunction return timingFunction
} }
} }
return ("ease") return ("ease")
} }
// IsTimingFunctionValid returns "true" if the "timingFunction" argument is the valid timing function. func isTimingFunctionValid(timingFunction string) bool {
func IsTimingFunctionValid(timingFunction string, session Session) bool {
switch timingFunction { switch timingFunction {
case "", EaseTiming, EaseInTiming, EaseOutTiming, EaseInOutTiming, LinearTiming: case "", EaseTiming, EaseInTiming, EaseOutTiming, EaseInOutTiming, LinearTiming:
return true return true
} }
if timingFunc, ok := session.resolveConstants(timingFunction); ok {
timingFunction = timingFunc
size := len(timingFunction) size := len(timingFunction)
if size > 0 && timingFunction[size-1] == ')' { if size > 0 && timingFunction[size-1] == ')' {
if index := strings.IndexRune(timingFunction, '('); index > 0 { if index := strings.IndexRune(timingFunction, '('); index > 0 {
@ -531,8 +528,15 @@ func IsTimingFunctionValid(timingFunction string, session Session) bool {
} }
} }
} }
return false
} }
// IsTimingFunctionValid returns "true" if the "timingFunction" argument is the valid timing function.
func IsTimingFunctionValid(timingFunction string, session Session) bool {
if timingFunc, ok := session.resolveConstants(strings.Trim(timingFunction, " \t\n")); ok {
return isTimingFunctionValid(timingFunc)
}
return false return false
} }