forked from mbk-lab/rui_orig
Added IsTimingFunctionValid function
This commit is contained in:
parent
f3f3ddb084
commit
38a8fd2920
|
@ -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
|
||||||
|
|
42
animation.go
42
animation.go
|
@ -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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,6 @@ ul:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.ruiRoot {
|
.ruiRoot {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
|
|
Loading…
Reference in New Issue