forked from mbk-lab/rui_orig
2
0
Fork 0

Added IsTimingFunctionValid function

This commit is contained in:
Alexei Anoshenko 2022-08-11 19:12:29 +03:00
parent f3f3ddb084
commit 38a8fd2920
3 changed files with 24 additions and 21 deletions

View File

@ -5,7 +5,7 @@
* Added "overflow", "arrow", "arrow-align", "arrow-size", "arrow-width", and "arrow-offset" properties * Added "overflow", "arrow", "arrow-align", "arrow-size", "arrow-width", and "arrow-offset" properties
* Added "@ruiArrowSize" and "@ruiArrowWidth" constants to the default theme * Added "@ruiArrowSize" and "@ruiArrowWidth" constants to the default theme
* Added Transition, Transitions, and SetTransition functions to the ViewStyle interface * Added Transition, Transitions, and SetTransition functions to the ViewStyle interface
* Added GetOverflow, and GetTransitions functions * Added GetOverflow, IsTimingFunctionValid, and GetTransitions functions
* Changed GetTransition functions * Changed GetTransition functions
# v0.8.0 # v0.8.0

View File

@ -493,37 +493,41 @@ 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 && validateTimingFunction(timingFunction) { if timingFunction, ok = session.resolveConstants(timingFunction); ok && IsTimingFunctionValid(timingFunction, session) {
return timingFunction return timingFunction
} }
} }
return ("ease") return ("ease")
} }
func validateTimingFunction(timingFunction string) bool { // IsTimingFunctionValid returns "true" if the "timingFunction" argument is the valid timing function.
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
} }
size := len(timingFunction) if timingFunc, ok := session.resolveConstants(timingFunction); ok {
if size > 0 && timingFunction[size-1] == ')' { timingFunction = timingFunc
if index := strings.IndexRune(timingFunction, '('); index > 0 { size := len(timingFunction)
args := timingFunction[index+1 : size-1] if size > 0 && timingFunction[size-1] == ')' {
switch timingFunction[:index] { if index := strings.IndexRune(timingFunction, '('); index > 0 {
case "steps": args := timingFunction[index+1 : size-1]
if _, err := strconv.Atoi(strings.Trim(args, " \t\n")); err == nil { switch timingFunction[:index] {
return true case "steps":
} if _, err := strconv.Atoi(strings.Trim(args, " \t\n")); err == nil {
return true
case "cubic-bezier": }
if params := strings.Split(args, ","); len(params) == 4 {
for _, param := range params { case "cubic-bezier":
if _, err := strconv.ParseFloat(strings.Trim(param, " \t\n"), 64); err != nil { if params := strings.Split(args, ","); len(params) == 4 {
return false for _, param := range params {
} if _, err := strconv.ParseFloat(strings.Trim(param, " \t\n"), 64); err != nil {
return false
}
}
return true
} }
return true
} }
} }
} }

View File

@ -59,7 +59,6 @@ ul:focus {
outline: none; outline: none;
} }
.ruiRoot { .ruiRoot {
position: absolute; position: absolute;
top: 0px; top: 0px;