コード例 #1
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                thisRef    = DotNetObjectReference.Create(this);
                clsBuilder = HtmlPropertyBuilder.CreateCssClassBuilder()
                             .Add("blazor-animation")
                             .Add(Cls?.Split(' ') ?? new string[0]);

                await JSRuntime.InvokeVoidAsync("RegisterAnimationBegin", thisRef, animationElement);

                styleBuilder = HtmlPropertyBuilder.CreateCssStyleBuilder()
                               .Add(InitialStyle?.Split(';') ?? new string[0])
                               .AddIf(IsAbsolute, "position:absolute")
                               .Add("transition:all 1s ease");
                if (paths.Any())
                {
                    var firstStyle = paths.Peek();
                    styleBuilder.Remove("transition").Add($"transition:all {(firstStyle.Duration <= 0 ? 1000 : firstStyle.Duration)}ms ease");
                }
                MarkAsRequireRender();
                StateHasChanged();
                return;
            }
            if (!animationBegined)
            {
                animationBegined = true;
                await AnimationElementLoadAsync();
            }
        }
コード例 #2
0
ファイル: StyleDebug.cs プロジェクト: zvars/UnityCsReference
        public static void FindSpecifiedStyles(ComputedStyle computedStyle, IEnumerable <SelectorMatchRecord> matchRecords, Dictionary <StylePropertyId, int> result)
        {
            result.Clear();

            if (computedStyle == null)
            {
                return;
            }

            // Find matched styles
            foreach (var record in matchRecords)
            {
                int specificity = record.complexSelector.specificity;
                if (record.sheet.isUnityStyleSheet)
                {
                    specificity = UnitySpecificity;
                }

                var properties = record.complexSelector.rule.properties;
                foreach (var property in properties)
                {
                    StylePropertyId id;
                    if (StylePropertyUtil.s_NameToId.TryGetValue(property.name, out id))
                    {
                        if (IsShorthandProperty(id))
                        {
                            var longhands = GetLonghandPropertyNames(id);
                            foreach (var longhand in longhands)
                            {
                                var longhandId = GetStylePropertyIdFromName(longhand);
                                result[longhandId] = specificity;
                            }
                        }
                        else
                        {
                            result[id] = specificity;
                        }
                    }
                }
            }

            // Find inherited properties
            var inheritedPropId = StyleDebug.GetInheritedProperties();

            foreach (var id in inheritedPropId)
            {
                if (result.ContainsKey(id))
                {
                    continue;
                }

                var value        = StyleDebug.GetComputedStyleValue(computedStyle, id);
                var initialValue = StyleDebug.GetComputedStyleValue(InitialStyle.Get(), id);

                if (!value.Equals(initialValue))
                {
                    result[id] = InheritedSpecificity;
                }
            }
        }
コード例 #3
0
        public static ComputedStyle Create(bool isShared = true)
        {
            var cs = new ComputedStyle(isShared);

            cs.CopyFrom(InitialStyle.Get());
            return(cs);
        }
コード例 #4
0
 public static ComputedStyle Create()
 {
     return(InitialStyle.Acquire());
 }
コード例 #5
0
 private void ApplyAllPropertyInitial()
 {
     CopyFrom(ref InitialStyle.Get());
 }
コード例 #6
0
        public static void FindSpecifiedStyles(ComputedStyle computedStyle, IEnumerable <SelectorMatchRecord> matchRecords, Dictionary <StylePropertyId, int> result)
        {
            result.Clear();
            bool flag = computedStyle == null;

            if (!flag)
            {
                foreach (SelectorMatchRecord current in matchRecords)
                {
                    int  value             = current.complexSelector.specificity;
                    bool isUnityStyleSheet = current.sheet.isUnityStyleSheet;
                    if (isUnityStyleSheet)
                    {
                        value = -1;
                    }
                    StyleProperty[] properties = current.complexSelector.rule.properties;
                    StyleProperty[] array      = properties;
                    for (int i = 0; i < array.Length; i++)
                    {
                        StyleProperty   styleProperty = array[i];
                        StylePropertyId stylePropertyId;
                        bool            flag2 = StylePropertyUtil.s_NameToId.TryGetValue(styleProperty.name, out stylePropertyId);
                        if (flag2)
                        {
                            bool flag3 = StyleDebug.IsShorthandProperty(stylePropertyId);
                            if (flag3)
                            {
                                string[] longhandPropertyNames = StyleDebug.GetLonghandPropertyNames(stylePropertyId);
                                string[] array2 = longhandPropertyNames;
                                for (int j = 0; j < array2.Length; j++)
                                {
                                    string          name = array2[j];
                                    StylePropertyId stylePropertyIdFromName = StyleDebug.GetStylePropertyIdFromName(name);
                                    result[stylePropertyIdFromName] = value;
                                }
                            }
                            else
                            {
                                result[stylePropertyId] = value;
                            }
                        }
                    }
                }
                StylePropertyId[] inheritedProperties = StyleDebug.GetInheritedProperties();
                StylePropertyId[] array3 = inheritedProperties;
                for (int k = 0; k < array3.Length; k++)
                {
                    StylePropertyId stylePropertyId2 = array3[k];
                    bool            flag4            = result.ContainsKey(stylePropertyId2);
                    if (!flag4)
                    {
                        object computedStyleValue  = StyleDebug.GetComputedStyleValue(computedStyle, stylePropertyId2);
                        object computedStyleValue2 = StyleDebug.GetComputedStyleValue(InitialStyle.Get(), stylePropertyId2);
                        bool   flag5 = !computedStyleValue.Equals(computedStyleValue2);
                        if (flag5)
                        {
                            result[stylePropertyId2] = 2147483646;
                        }
                    }
                }
            }
        }