internal void AddPathConfig(TransitionOption option)
 {
     if (!IsAbsolute && (option.Style.StartsWith("top:") || option.Style.StartsWith("left:") || option.Style.Contains(";top:") || option.Style.Contains(";left:")))
     {
         IsAbsolute = true;
     }
     paths.Enqueue(option);
 }
Beispiel #2
0
        protected override void OnInitialized()
        {
            base.OnInitialized();
            var option = new TransitionOption();

            option.Style     = string.IsNullOrWhiteSpace(Style) ? string.Join(";", Attributes.Select(x => $"{x.Key}:{x.Value.ToString()}")) : Style;
            option.Delay     = Delay;
            option.Increment = Increment;
            option.Duration  = Duration;
            option.Pause     = Pause;
            Transition.AddPathConfig(option);
        }
        public async Task AnimationEndAsync(string propertyName)
        {
            if (currentStyleNames != null)
            {
                if (!currentStyleNames.Remove(propertyName))
                {
                    Console.WriteLine("样式移除失败:" + propertyName + ",还有" + currentStyleNames.Count + "个样式等待移除");
                }
                else
                {
                    Console.WriteLine($"{propertyName}移除成功,还有{currentStyleNames.Count  }个样式等待移除");
                    while (currentStyleNames.Contains(propertyName))
                    {
                        currentStyleNames.Remove(propertyName);
                    }
                    if (currentStyleNames.Any())
                    {
                        return;
                    }
                }
            }

            if (!animating)
            {
                return;
            }
            animating = false;
            if (paths == null || !paths.Any())
            {
                if (OnAllEnd.HasDelegate)
                {
                    await OnAllEnd.InvokeAsync(null);
                }
                return;
            }
            currentPath = paths.Dequeue();
            if (currentPath.Pause.HasValue && currentPath.Pause.Value)
            {
                if (OnPause.HasDelegate)
                {
                    await OnPause.InvokeAsync(null);
                }
                taskTrigger = new TaskCompletionSource <int>();
                await taskTrigger.Task;
                taskTrigger = null;
            }
            await Task.Delay(currentPath.Delay);

            styleBuilder.Remove("transition").Add($"transition:all {(currentPath.Duration <= 0 ? 1000 : currentPath.Duration)}ms ease");
            ExecuteAnimation(currentPath.Style, currentPath.Increment);
        }
        private async Task AnimationElementLoadAsync()
        {
            if (paths == null || !paths.Any())
            {
                return;
            }
            if (AutoAdjustPosition)
            {
                var rect = await animationElement.Dom(JSRuntime).GetBoundingClientRectAsync();

                var screenWidth = await Document.GetClientWidthAsync();

                var left = screenWidth / 2 - rect.Width / 2;
                styleBuilder.Add($"left:{left}px");
            }
            currentPath = paths.Dequeue();
            await Task.Delay(currentPath.Delay);

            ExecuteAnimation(currentPath.Style, currentPath.Increment);
        }