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 {
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 ("ease")
}
// IsTimingFunctionValid returns "true" if the "timingFunction" argument is the valid timing function.
func IsTimingFunctionValid(timingFunction string, session Session) bool {
func isTimingFunctionValid(timingFunction string) bool {
switch timingFunction {
case "", EaseTiming, EaseInTiming, EaseOutTiming, EaseInOutTiming, LinearTiming:
return true
}
if timingFunc, ok := session.resolveConstants(timingFunction); ok {
timingFunction = timingFunc
size := len(timingFunction)
if size > 0 && timingFunction[size-1] == ')' {
if index := strings.IndexRune(timingFunction, '('); index > 0 {
@ -531,11 +528,18 @@ 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
}
func (session *sessionData) registerAnimation(props []AnimatedProperty) string {
session.animationCounter++