diff --git a/CHANGELOG.md b/CHANGELOG.md index cecc189..c0227ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ PolygonPointsClip function -> NewPolygonPointsClip ViewFilter interface -> FilterProperty NewViewFilter function -> NewFilterProperty + Animation interface -> AnimationProperty + AnimationTag constant -> Animation * Added functions: NewBounds, NewEllipticRadius, NewRadii, NewLinearGradient, NewCircleRadialGradient, NewEllipseRadialGradient, GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation, diff --git a/README-ru.md b/README-ru.md index 0ee8d23..2beca26 100644 --- a/README-ru.md +++ b/README-ru.md @@ -5038,14 +5038,14 @@ onNo или onCancel (если она не nil). * Анимированное изменения значения свойства (далее "анимация перехода") * Сценарий анимированного изменения одного или нескольких свойств (далее просто "сценарий анимации") -### Интерфейс Animation +### Интерфейс AnimationProperty -Для задания параметров анимации используется интерфейс Animation. Он расширяет интерфейс Properties. +Для задания параметров анимации используется интерфейс AnimationProperty. Он расширяет интерфейс Properties. Интерфейс создается с помощью функции: - func NewAnimation(params Params) Animation + func NewAnimation(params Params) AnimationProperty -Часть свойств интерфейса Animation используется в обоих типах анимации, остальные используются +Часть свойств интерфейса AnimationProperty используется в обоих типах анимации, остальные используются только в сценариях анимации. Общими свойствами являются @@ -5112,7 +5112,7 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете Однократная анимация запускается с помощью функции SetAnimated интерфейса View. Данная функция имеет следующее описание: - SetAnimated(tag string, value any, animation Animation) bool + SetAnimated(tag string, value any, animation AnimationProperty) bool Она присваивает свойству новое значение, при этом изменение происходит с использованием заданной анимации. Например, @@ -5124,11 +5124,11 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете Есть также глобальная функция для анимированного однократного изменения значения свойства дочернего View - func SetAnimated(rootView View, viewID, tag string, value any, animation Animation) bool + func SetAnimated(rootView View, viewID, tag string, value any, animation AnimationProperty) bool Постоянная анимация запускается каждый раз когда изменяется значение свойства. Для задания постоянной анимации перехода используется свойство "transition" (константа Transition). В качества значения данному -Свойству присваивается rui.Params, где в качестве ключа должно быть имя свойства, а значение - интерфейс Animation. +Свойству присваивается rui.Params, где в качестве ключа должно быть имя свойства, а значение - интерфейс AnimationProperty. Например, view.Set(rui.Transition, rui.Params{ @@ -5151,7 +5151,7 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете Добавлять новые анимации перехода рекомендуется с помощью функции - func AddTransition(view View, subviewID, tag string, animation Animation) bool + func AddTransition(view View, subviewID, tag string, animation AnimationProperty) bool Вызов данной функции эквивалентен следующему коду @@ -5192,7 +5192,7 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете ### Сценарий анимации Сценарий анимации описывает более сложную анимацию, по сравнению с анимацией перехода. Для этого -в Animation добавляются дополнительные свойства: +в AnimationProperty добавляются дополнительные свойства: #### Свойство "property" @@ -5256,11 +5256,11 @@ KeyFrames - промежуточные значения свойства (клю #### Запуск анимации -Для запуска сценария анимации необходимо созданный Animation интерфейс присвоить свойству "animation" -(константа AnimationTag). Если View уже отображается на экране, то анимация запускается сразу (с учетом +Для запуска сценария анимации необходимо созданный AnimationProperty интерфейс присвоить свойству "animation" +(константа Animation). Если View уже отображается на экране, то анимация запускается сразу (с учетом заданной задержки), в противоположном случае анимация запускается как только View отобразится на экране. -Свойству "animation" можно присваивать Animation и []Animation, т.е. можно запускать несколько анимаций +Свойству "animation" можно присваивать AnimationProperty и []AnimationProperty, т.е. можно запускать несколько анимаций одновременно для одного View Пример, @@ -5278,7 +5278,7 @@ KeyFrames - промежуточные значения свойства (клю rui.Duration: 2, rui.TimingFunction: LinearTiming, }) - rui.Set(view, "subview", rui.AnimationTag, animation) + rui.Set(view, "subview", rui.Animation, animation) #### Свойство "animation-paused" diff --git a/README.md b/README.md index e233f6f..c63510c 100644 --- a/README.md +++ b/README.md @@ -5009,14 +5009,14 @@ The library supports two types of animation: * Animated property value changes (hereinafter "transition animation") * Script animated change of one or more properties (hereinafter simply "animation script") -### Animation interface +### AnimationProperty interface -The Animation interface is used to set animation parameters. It extends the Properties interface. +The AnimationProperty interface is used to set animation parameters. It extends the Properties interface. The interface is created using the function: - func NewAnimation(params Params) Animation + func NewAnimation(params Params) AnimationProperty -Some of the properties of the Animation interface are used in both types of animation, the rest are used only +Some of the properties of the AnimationProperty interface are used in both types of animation, the rest are used only in animation scripts. Common properties are @@ -5082,7 +5082,7 @@ There are two types of transition animations: A one-time animation is triggered using the SetAnimated function of the View interface. This function has the following description: - SetAnimated(tag string, value any, animation Animation) bool + SetAnimated(tag string, value any, animation AnimationProperty) bool It assigns a new value to the property, and the change occurs using the specified animation. For example, @@ -5094,12 +5094,12 @@ For example, There is also a global function for animated one-time change of the property value of the child View - func SetAnimated(rootView View, viewID, tag string, value any, animation Animation) bool + func SetAnimated(rootView View, viewID, tag string, value any, animation AnimationProperty) bool A persistent animation runs every time the property value changes. To set the constant animation of the transition, use the "transition" property (the Transition constant). As a value, this property is assigned rui.Params, where the property name should be the key, -and the value should be the Animation interface. +and the value should be the AnimationProperty interface. For example, view.Set(rui.Transition, rui.Params{ @@ -5122,7 +5122,7 @@ To get the current list of permanent transition animations, use the function It is recommended to add new transition animations using the function - func AddTransition(view View, subviewID, tag string, animation Animation) bool + func AddTransition(view View, subviewID, tag string, animation AnimationProperty) bool Calling this function is equivalent to the following code @@ -5162,7 +5162,7 @@ Get lists of listeners for transition animation events using functions: ### Animation script -An animation script describes a more complex animation than a transition animation. To do this, additional properties are added to Animation: +An animation script describes a more complex animation than a transition animation. To do this, additional properties are added to AnimationProperty: #### "property" property @@ -5228,12 +5228,12 @@ backward playback of the sequence. It can take the following values: #### Animation start -To start the animation script, you must assign the interface created by Animation to the "animation" property -(the AnimationTag constant). If the View is already displayed on the screen, then the animation starts immediately +To start the animation script, you must assign the interface created by AnimationProperty to the "animation" property +(the Animation constant). If the View is already displayed on the screen, then the animation starts immediately (taking into account the specified delay), otherwise the animation starts as soon as the View is displayed on the screen. -The "animation" property can be assigned Animation and [] Animation, ie. you can run several animations +The "animation" property can be assigned AnimationProperty and [] AnimationProperty, ie. you can run several animations at the same time for one View Example, @@ -5251,7 +5251,7 @@ Example, rui.Duration: 2, rui.TimingFunction: LinearTiming, }) - rui.Set(view, "subview", rui.AnimationTag, animation) + rui.Set(view, "subview", rui.Animation, animation) #### "animation-paused" property diff --git a/animation.go b/animation.go index b187f20..f2e3034 100644 --- a/animation.go +++ b/animation.go @@ -9,20 +9,20 @@ import ( // Constants which related to view's animation const ( - // AnimationTag is the constant for "animation" property tag. + // Animation is the constant for "animation" property tag. // // Used by View. // Sets and starts animations. // - // Supported types: Animation, []Animation. + // Supported types: AnimationProperty, []AnimationProperty. // - // Internal type is []Animation, other types converted to it during assignment. - // See Animation description for more details. - AnimationTag PropertyName = "animation" + // Internal type is []AnimationProperty, other types converted to it during assignment. + // See AnimationProperty description for more details. + Animation PropertyName = "animation" // AnimationPaused is the constant for "animation-paused" property tag. // - // Used by Animation. + // Used by AnimationProperty. // Controls whether the animation is running or paused. // // Supported types: bool, int, string. @@ -36,7 +36,7 @@ const ( // // Used by View. // - // Sets transition animation of view properties. Each provided property must contain Animation which describe how + // Sets transition animation of view properties. Each provided property must contain AnimationProperty which describe how // particular property will be animated on property value change. Transition animation can be applied to properties of the // type SizeUnit, Color, AngleUnit, float64 and composite properties that contain elements of the listed types(for // example, "shadow", "border", etc.). If we'll try to animate other properties with internal type like bool or @@ -49,7 +49,7 @@ const ( // PropertyTag is the constant for "property" property tag. // - // Used by Animation. + // Used by AnimationProperty. // // Describes a scenario for changing a View's property. Used only for animation script. // @@ -61,7 +61,7 @@ const ( // Duration is the constant for "duration" property tag. // - // Used by Animation. + // Used by AnimationProperty. // // Sets the length of time in seconds that an animation takes to complete one cycle. // @@ -72,7 +72,7 @@ const ( // Delay is the constant for "delay" property tag. // - // Used by Animation. + // Used by AnimationProperty. // // Specifies the amount of time in seconds to wait from applying the animation to an element before beginning to perform // the animation. The animation can start later, immediately from its beginning or immediately and partway through the @@ -85,7 +85,7 @@ const ( // TimingFunction is the constant for "timing-function" property tag. // - // Used by Animation. + // Used by AnimationProperty. // // Set how an animation progresses through the duration of each cycle. // @@ -103,7 +103,7 @@ const ( // IterationCount is the constant for "iteration-count" property tag. // - // Used by Animation. + // Used by AnimationProperty. // // Sets the number of times an animation sequence should be played before stopping. Used only for animation script. // @@ -114,7 +114,7 @@ const ( // AnimationDirection is the constant for "animation-direction" property tag. // - // Used by Animation. + // Used by AnimationProperty. // // Whether an animation should play forward, backward, or alternate back and forth between playing the sequence forward // and backward. Used only for animation script. @@ -208,21 +208,21 @@ type animationData struct { keyFramesName string usageCounter int view View - listener func(view View, animation Animation, event PropertyName) + listener func(view View, animation AnimationProperty, event PropertyName) oldListeners map[PropertyName][]func(View, PropertyName) - oldAnimation []Animation + oldAnimation []AnimationProperty } -// Animation interface is used to set animation parameters. Used properties: +// AnimationProperty interface is used to set animation parameters. Used properties: // // "property", "id", "duration", "delay", "timing-function", "iteration-count", and "animation-direction" -type Animation interface { +type AnimationProperty interface { Properties fmt.Stringer // Start starts the animation for the view specified by the first argument. // The second argument specifies the animation event listener (can be nil) - Start(view View, listener func(view View, animation Animation, event PropertyName)) bool + Start(view View, listener func(view View, animation AnimationProperty, event PropertyName)) bool // Stop stops the animation Stop() // Pause pauses the animation @@ -239,7 +239,7 @@ type Animation interface { unused(session Session) } -func parseAnimation(obj DataObject) Animation { +func parseAnimation(obj DataObject) AnimationProperty { animation := new(animationData) animation.init() @@ -257,7 +257,7 @@ func parseAnimation(obj DataObject) Animation { } // NewAnimation creates a new animation object and return its interface -func NewAnimation(params Params) Animation { +func NewAnimation(params Params) AnimationProperty { animation := new(animationData) animation.init() @@ -269,7 +269,7 @@ func NewAnimation(params Params) Animation { func (animation *animationData) init() { animation.dataProperty.init() - animation.normalize = normalizeAnimationTag + animation.normalize = normalizeAnimation animation.set = animationSet animation.supportedProperties = []PropertyName{ID, PropertyTag, Duration, Delay, TimingFunction, IterationCount, AnimationDirection} } @@ -314,7 +314,7 @@ func (animation *animationData) unused(session Session) { } } -func normalizeAnimationTag(tag PropertyName) PropertyName { +func normalizeAnimation(tag PropertyName) PropertyName { tag = defaultNormalize(tag) if tag == Direction { return AnimationDirection @@ -777,7 +777,7 @@ func (session *sessionData) registerAnimation(props []AnimatedProperty) string { return name } -func (view *viewData) SetAnimated(tag PropertyName, value any, animation Animation) bool { +func (view *viewData) SetAnimated(tag PropertyName, value any, animation AnimationProperty) bool { if animation == nil { return view.Set(tag, value) } @@ -790,7 +790,7 @@ func (view *viewData) SetAnimated(tag PropertyName, value any, animation Animati session.updateProperty(htmlID, "ontransitioncancel", "transitionCancelEvent(this, event)") transitions := getTransitionProperty(view) - var prevAnimation Animation = nil + var prevAnimation AnimationProperty = nil if transitions != nil { if prev, ok := transitions[tag]; ok { prevAnimation = prev @@ -812,8 +812,8 @@ func (view *viewData) SetAnimated(tag PropertyName, value any, animation Animati } func animationCSS(properties Properties, session Session) string { - if value := properties.getRaw(AnimationTag); value != nil { - if animations, ok := value.([]Animation); ok { + if value := properties.getRaw(Animation); value != nil { + if animations, ok := value.([]AnimationProperty); ok { buffer := allocStringBuilder() defer freeStringBuilder(buffer) @@ -874,7 +874,7 @@ func (view *viewData) updateTransitionCSS() { } */ -func (style *viewStyle) Transition(tag PropertyName) Animation { +func (style *viewStyle) Transition(tag PropertyName) AnimationProperty { if transitions := getTransitionProperty(style); transitions != nil { if anim, ok := transitions[tag]; ok { return anim @@ -883,26 +883,26 @@ func (style *viewStyle) Transition(tag PropertyName) Animation { return nil } -func (style *viewStyle) Transitions() map[PropertyName]Animation { - result := map[PropertyName]Animation{} +func (style *viewStyle) Transitions() map[PropertyName]AnimationProperty { + result := map[PropertyName]AnimationProperty{} for tag, animation := range getTransitionProperty(style) { result[tag] = animation } return result } -func (style *viewStyle) SetTransition(tag PropertyName, animation Animation) { +func (style *viewStyle) SetTransition(tag PropertyName, animation AnimationProperty) { setTransition(style, style.normalize(tag), animation) } -func (view *viewData) SetTransition(tag PropertyName, animation Animation) { +func (view *viewData) SetTransition(tag PropertyName, animation AnimationProperty) { setTransition(view, view.normalize(tag), animation) if view.created { view.session.updateCSSProperty(view.htmlID(), "transition", transitionCSS(view, view.session)) } } -func setTransition(properties Properties, tag PropertyName, animation Animation) { +func setTransition(properties Properties, tag PropertyName, animation AnimationProperty) { transitions := getTransitionProperty(properties) if animation == nil { @@ -915,13 +915,13 @@ func setTransition(properties Properties, tag PropertyName, animation Animation) } else if transitions != nil { transitions[tag] = animation } else { - properties.setRaw(Transition, map[PropertyName]Animation{tag: animation}) + properties.setRaw(Transition, map[PropertyName]AnimationProperty{tag: animation}) } } -func getTransitionProperty(properties Properties) map[PropertyName]Animation { +func getTransitionProperty(properties Properties) map[PropertyName]AnimationProperty { if value := properties.getRaw(Transition); value != nil { - if transitions, ok := value.(map[PropertyName]Animation); ok { + if transitions, ok := value.(map[PropertyName]AnimationProperty); ok { return transitions } } @@ -930,7 +930,7 @@ func getTransitionProperty(properties Properties) map[PropertyName]Animation { func setAnimationProperty(properties Properties, tag PropertyName, value any) bool { - set := func(animations []Animation) { + set := func(animations []AnimationProperty) { properties.setRaw(tag, animations) for _, animation := range animations { animation.used() @@ -938,22 +938,22 @@ func setAnimationProperty(properties Properties, tag PropertyName, value any) bo } switch value := value.(type) { - case Animation: - set([]Animation{value}) + case AnimationProperty: + set([]AnimationProperty{value}) return true - case []Animation: + case []AnimationProperty: set(value) return true case DataObject: if animation := parseAnimation(value); animation.hasAnimatedProperty() { - set([]Animation{animation}) + set([]AnimationProperty{animation}) return true } case DataNode: - animations := []Animation{} + animations := []AnimationProperty{} result := true for i := 0; i < value.ArraySize(); i++ { if obj := value.ArrayElement(i).Object(); obj != nil { @@ -980,7 +980,7 @@ func setAnimationProperty(properties Properties, tag PropertyName, value any) bo // SetAnimated sets the property with name "tag" of the "rootView" subview with "viewID" id by value. Result: // true - success, // false - error (incompatible type or invalid format of a string value, see AppLog). -func SetAnimated(rootView View, viewID string, tag PropertyName, value any, animation Animation) bool { +func SetAnimated(rootView View, viewID string, tag PropertyName, value any, animation AnimationProperty) bool { if view := ViewByID(rootView, viewID); view != nil { return view.SetAnimated(tag, value, animation) } @@ -995,17 +995,17 @@ func IsAnimationPaused(view View, subviewID ...string) bool { // GetTransitions returns the subview transitions. The result is always non-nil. // If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned -func GetTransitions(view View, subviewID ...string) map[PropertyName]Animation { +func GetTransitions(view View, subviewID ...string) map[PropertyName]AnimationProperty { if view = getSubview(view, subviewID); view != nil { return view.Transitions() } - return map[PropertyName]Animation{} + return map[PropertyName]AnimationProperty{} } // GetTransition returns the subview property transition. If there is no transition for the given property then nil is returned. // If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned -func GetTransition(view View, subviewID string, tag PropertyName) Animation { +func GetTransition(view View, subviewID string, tag PropertyName) AnimationProperty { if subviewID != "" { view = ViewByID(view, subviewID) } @@ -1019,7 +1019,7 @@ func GetTransition(view View, subviewID string, tag PropertyName) Animation { // AddTransition adds the transition for the subview property. // If the second argument (subviewID) is not specified or it is "" then the transition is added to the first argument (view) -func AddTransition(view View, subviewID string, tag PropertyName, animation Animation) bool { +func AddTransition(view View, subviewID string, tag PropertyName, animation AnimationProperty) bool { if tag != "" { if subviewID != "" { view = ViewByID(view, subviewID) @@ -1035,14 +1035,14 @@ func AddTransition(view View, subviewID string, tag PropertyName, animation Anim // GetAnimation returns the subview animations. The result is always non-nil. // If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned -func GetAnimation(view View, subviewID ...string) []Animation { +func GetAnimation(view View, subviewID ...string) []AnimationProperty { if view = getSubview(view, subviewID); view != nil { - if value := view.getRaw(AnimationTag); value != nil { - if animations, ok := value.([]Animation); ok && animations != nil { + if value := view.getRaw(Animation); value != nil { + if animations, ok := value.([]AnimationProperty); ok && animations != nil { return animations } } } - return []Animation{} + return []AnimationProperty{} } diff --git a/animationRun.go b/animationRun.go index 683e359..e9f1eeb 100644 --- a/animationRun.go +++ b/animationRun.go @@ -1,6 +1,6 @@ package rui -func (animation *animationData) Start(view View, listener func(view View, animation Animation, event PropertyName)) bool { +func (animation *animationData) Start(view View, listener func(view View, animation AnimationProperty, event PropertyName)) bool { if view == nil { ErrorLog("nil View in animation.Start() function") return false @@ -13,8 +13,8 @@ func (animation *animationData) Start(view View, listener func(view View, animat animation.listener = listener animation.oldAnimation = nil - if value := view.Get(AnimationTag); value != nil { - if oldAnimation, ok := value.([]Animation); ok && len(oldAnimation) > 0 { + if value := view.Get(Animation); value != nil { + if oldAnimation, ok := value.([]AnimationProperty); ok && len(oldAnimation) > 0 { animation.oldAnimation = oldAnimation } } @@ -42,7 +42,7 @@ func (animation *animationData) Start(view View, listener func(view View, animat setListeners(AnimationCancelEvent, animation.onAnimationCancel) setListeners(AnimationIterationEvent, animation.onAnimationIteration) - view.Set(AnimationTag, animation) + view.Set(Animation, animation) return true } @@ -57,10 +57,10 @@ func (animation *animationData) finish() { } if animation.oldAnimation != nil { - animation.view.Set(AnimationTag, animation.oldAnimation) + animation.view.Set(Animation, animation.oldAnimation) animation.oldAnimation = nil } else { - animation.view.Set(AnimationTag, "") + animation.view.Set(Animation, "") } animation.oldListeners = map[PropertyName][]func(View, PropertyName){} diff --git a/customView.go b/customView.go index 06c673d..e8f8afb 100644 --- a/customView.go +++ b/customView.go @@ -89,7 +89,7 @@ func (customView *CustomViewData) Set(tag PropertyName, value any) bool { // SetAnimated sets the value (second argument) of the property with name defined by the first argument. // Return "true" if the value has been set, in the opposite case "false" are returned and // a description of the error is written to the log -func (customView *CustomViewData) SetAnimated(tag PropertyName, value any, animation Animation) bool { +func (customView *CustomViewData) SetAnimated(tag PropertyName, value any, animation AnimationProperty) bool { return customView.superView.SetAnimated(tag, value, animation) } @@ -323,7 +323,7 @@ func (customView *CustomViewData) setScroll(x, y, width, height float64) { } // Transition returns the transition animation of the property(tag). Returns nil is there is no transition animation. -func (customView *CustomViewData) Transition(tag PropertyName) Animation { +func (customView *CustomViewData) Transition(tag PropertyName) AnimationProperty { if customView.superView != nil { return customView.superView.Transition(tag) } @@ -331,17 +331,17 @@ func (customView *CustomViewData) Transition(tag PropertyName) Animation { } // Transitions returns a map of transition animations. The result is always non-nil. -func (customView *CustomViewData) Transitions() map[PropertyName]Animation { +func (customView *CustomViewData) Transitions() map[PropertyName]AnimationProperty { if customView.superView != nil { return customView.superView.Transitions() } - return map[PropertyName]Animation{} + return map[PropertyName]AnimationProperty{} } // SetTransition sets the transition animation for the property if "animation" argument is not nil, and // removes the transition animation of the property if "animation" argument is nil. // The "tag" argument is the property name. -func (customView *CustomViewData) SetTransition(tag PropertyName, animation Animation) { +func (customView *CustomViewData) SetTransition(tag PropertyName, animation AnimationProperty) { if customView.superView != nil { customView.superView.SetTransition(tag, animation) } diff --git a/view.go b/view.go index 49bf2ee..d6ee7f8 100644 --- a/view.go +++ b/view.go @@ -62,7 +62,7 @@ type View interface { // SetAnimated sets the value (second argument) of the property with name defined by the first argument. // Return "true" if the value has been set, in the opposite case "false" are returned and // a description of the error is written to the log - SetAnimated(tag PropertyName, value any, animation Animation) bool + SetAnimated(tag PropertyName, value any, animation AnimationProperty) bool // SetChangeListener set the function to track the change of the View property SetChangeListener(tag PropertyName, listener func(View, PropertyName)) @@ -102,7 +102,7 @@ type viewData struct { parentID string systemClass string changeListener map[PropertyName]func(View, PropertyName) - singleTransition map[PropertyName]Animation + singleTransition map[PropertyName]AnimationProperty addCSS map[string]string frame Frame scroll Frame @@ -155,7 +155,7 @@ func (view *viewData) init(session Session) { view.changeListener = map[PropertyName]func(View, PropertyName){} view.addCSS = map[string]string{} //view.animation = map[string]AnimationEndListener{} - view.singleTransition = map[PropertyName]Animation{} + view.singleTransition = map[PropertyName]AnimationProperty{} view.noResizeEvent = false view.created = false view.hasHtmlDisabled = false @@ -294,16 +294,16 @@ func (view *viewData) removeFunc(tag PropertyName) []PropertyName { changedTags = []PropertyName{} } - case AnimationTag: - if val := view.getRaw(AnimationTag); val != nil { - if animations, ok := val.([]Animation); ok { + case Animation: + if val := view.getRaw(Animation); val != nil { + if animations, ok := val.([]AnimationProperty); ok { for _, animation := range animations { animation.unused(view.session) } } - view.setRaw(AnimationTag, nil) - changedTags = []PropertyName{AnimationTag} + view.setRaw(Animation, nil) + changedTags = []PropertyName{Animation} } default: @@ -326,10 +326,10 @@ func (view *viewData) setFunc(tag PropertyName, value any) []PropertyName { notCompatibleType(ID, value) return nil - case AnimationTag: - oldAnimations := []Animation{} - if val := view.getRaw(AnimationTag); val != nil { - if animation, ok := val.([]Animation); ok { + case Animation: + oldAnimations := []AnimationProperty{} + if val := view.getRaw(Animation); val != nil { + if animation, ok := val.([]AnimationProperty); ok { oldAnimations = animation } } @@ -341,7 +341,7 @@ func (view *viewData) setFunc(tag PropertyName, value any) []PropertyName { for _, animation := range oldAnimations { animation.unused(view.session) } - return []PropertyName{AnimationTag} + return []PropertyName{Animation} case TabIndex, "tab-index": return setIntProperty(view, TabIndex, value) @@ -635,7 +635,7 @@ func (view *viewData) propertyChanged(tag PropertyName) { case Transition: session.updateCSSProperty(htmlID, "transition", transitionCSS(view, session)) - case AnimationTag: + case Animation: session.updateCSSProperty(htmlID, "animation", animationCSS(view, session)) case AnimationPaused: diff --git a/viewStyle.go b/viewStyle.go index d172038..40f1931 100644 --- a/viewStyle.go +++ b/viewStyle.go @@ -12,15 +12,15 @@ type ViewStyle interface { Properties // Transition returns the transition animation of the property. Returns nil is there is no transition animation. - Transition(tag PropertyName) Animation + Transition(tag PropertyName) AnimationProperty // Transitions returns the map of transition animations. The result is always non-nil. - Transitions() map[PropertyName]Animation + Transitions() map[PropertyName]AnimationProperty // SetTransition sets the transition animation for the property if "animation" argument is not nil, and // removes the transition animation of the property if "animation" argument is nil. // The "tag" argument is the property name. - SetTransition(tag PropertyName, animation Animation) + SetTransition(tag PropertyName, animation AnimationProperty) cssViewStyle(buffer cssBuilder, session Session) } @@ -412,7 +412,7 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) { } if animation := animationCSS(style, session); animation != "" { - builder.add(string(AnimationTag), animation) + builder.add(string(Animation), animation) } if pause, ok := boolProperty(style, AnimationPaused, session); ok { @@ -566,7 +566,7 @@ func supportedPropertyValue(value any) bool { case []BackgroundElement: case []BackgroundGradientPoint: case []BackgroundGradientAngle: - case map[PropertyName]Animation: + case map[PropertyName]AnimationProperty: default: return false } @@ -775,7 +775,7 @@ func writePropertyValue(buffer *strings.Builder, tag PropertyName, value any, in } buffer.WriteRune('"') - case map[PropertyName]Animation: + case map[PropertyName]AnimationProperty: switch count := len(value); count { case 0: buffer.WriteString("[]") diff --git a/viewStyleSet.go b/viewStyleSet.go index 227b742..184c1e8 100644 --- a/viewStyleSet.go +++ b/viewStyleSet.go @@ -6,7 +6,7 @@ import ( func setTransitionProperty(properties Properties, value any) bool { - transitions := map[PropertyName]Animation{} + transitions := map[PropertyName]AnimationProperty{} setObject := func(obj DataObject) bool { if obj != nil { @@ -33,7 +33,7 @@ func setTransitionProperty(properties Properties, value any) bool { } if val != nil { - if animation, ok := val.(Animation); ok { + if animation, ok := val.(AnimationProperty); ok { transitions[PropertyName(tag)] = animation } else { notCompatibleType(Transition, val) @@ -424,7 +424,7 @@ func viewStyleSet(style Properties, tag PropertyName, value any) []PropertyName return nil } - case AnimationTag: + case Animation: if setAnimationProperty(style, tag, value) { return []PropertyName{tag} } else {