forked from mbk-lab/rui_orig
Optimisation
This commit is contained in:
parent
38a8fd2920
commit
9a5fd64758
46
animation.go
46
animation.go
|
@ -493,41 +493,37 @@ 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 {
|
size := len(timingFunction)
|
||||||
timingFunction = timingFunc
|
if size > 0 && timingFunction[size-1] == ')' {
|
||||||
size := len(timingFunction)
|
if index := strings.IndexRune(timingFunction, '('); index > 0 {
|
||||||
if size > 0 && timingFunction[size-1] == ')' {
|
args := timingFunction[index+1 : size-1]
|
||||||
if index := strings.IndexRune(timingFunction, '('); index > 0 {
|
switch timingFunction[:index] {
|
||||||
args := timingFunction[index+1 : size-1]
|
case "steps":
|
||||||
switch timingFunction[:index] {
|
if _, err := strconv.Atoi(strings.Trim(args, " \t\n")); err == nil {
|
||||||
case "steps":
|
return true
|
||||||
if _, err := strconv.Atoi(strings.Trim(args, " \t\n")); err == nil {
|
}
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
case "cubic-bezier":
|
case "cubic-bezier":
|
||||||
if params := strings.Split(args, ","); len(params) == 4 {
|
if params := strings.Split(args, ","); len(params) == 4 {
|
||||||
for _, param := range params {
|
for _, param := range params {
|
||||||
if _, err := strconv.ParseFloat(strings.Trim(param, " \t\n"), 64); err != nil {
|
if _, err := strconv.ParseFloat(strings.Trim(param, " \t\n"), 64); err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -536,6 +532,14 @@ func IsTimingFunctionValid(timingFunction string, session Session) bool {
|
||||||
return false
|
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 {
|
func (session *sessionData) registerAnimation(props []AnimatedProperty) string {
|
||||||
|
|
||||||
session.animationCounter++
|
session.animationCounter++
|
||||||
|
|
Loading…
Reference in New Issue