protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { _jsAvailable = true; // register timers here so that pre-rendered Panels don't have timers running. _animationTimer = new Timer(); _clearExistingAnimationTimer = () => { if (_animationTimer.Enabled) { _animationTimer.Stop(); _animationTimer.Elapsed -= _handler; } }; _animateTo = (animationState) => { Debug.WriteLine($"Animating to {animationState}"); _animationTimer.Interval = 200; _handler = null; _handler = (s, e) => { _animationTimer.Stop(); _animationTimer.Elapsed -= _handler; Debug.WriteLine($"Inside invokeAsync from animateTo timer elapsed."); //InvokeAsync(() => //{ previousVisibility = currentVisibility; currentVisibility = animationState; _onTransitionComplete(); //}); }; _animationTimer.Elapsed += _handler; _animationTimer.Start(); }; _onTransitionComplete = async() => { isAnimating = false; //StateHasChanged(); await UpdateFooterPositionAsync(); if (currentVisibility == PanelVisibilityState.Open) { await OnOpened.InvokeAsync(null); } if (currentVisibility == PanelVisibilityState.Closed) { await OnDismissed.InvokeAsync(null); } InvokeAsync(StateHasChanged); }; } await SetRegistrationsAsync(); await base.OnAfterRenderAsync(firstRender); }
public void Activate(OnDismissed onDismissed) { Debug.Log("Activating signup modal..."); this.onDismissed = onDismissed; gameObject.SetActive(true); assets.audioClick.Play(); background.color = new Color(0, 0, 0, 0); background.DOFade(0.5f, 1f); window.DOLocalMoveY(0, 1f).SetEase(Ease.OutBounce); Util.Tween(0.35f, null, () => { assets.audioImpact.Play(); Camera.main.DOShakePosition(1.2f, 6, 12); }); }
public Panel() { Debug.WriteLine("Panel Created"); _animationTimer = new Timer(); HeaderTemplate = builder => { if (HeaderText != null) { builder.OpenElement(0, "div"); { builder.AddAttribute(1, "class", "ms-Panel-header"); builder.OpenElement(2, "p"); { builder.AddAttribute(3, "class", "xlargeFont ms-Panel-headerText"); //builder.AddAttribute(4, "id", ) builder.AddAttribute(5, "role", "heading"); builder.AddAttribute(6, "aria-level", "2"); builder.AddContent(7, HeaderText); } builder.CloseElement(); } builder.CloseElement(); } }; onPanelClick = () => { this._dismiss(); }; _dismiss = async() => { await OnDismiss.InvokeAsync(null); //normally, would check react synth events to see if event was interrupted from the OnDismiss callback before calling the following... // To Do this.Close(); }; _clearExistingAnimationTimer = () => { if (_animationTimer.Enabled) { _animationTimer.Stop(); _animationTimer.Elapsed -= _handler; } }; _animateTo = (animationState) => { _animationTimer.Interval = 200; _handler = null; _handler = (s, e) => { InvokeAsync(() => { //Debug.WriteLine("Inside invokeAsync from animateTo timer elapsed"); _animationTimer.Elapsed -= _handler; _animationTimer.Stop(); previousVisibility = currentVisibility; currentVisibility = animationState; _onTransitionComplete(); }); }; _animationTimer.Elapsed += _handler; _animationTimer.Start(); }; _onTransitionComplete = async() => { isAnimating = false; //StateHasChanged(); await UpdateFooterPositionAsync(); if (currentVisibility == PanelVisibilityState.Open) { await OnOpened.InvokeAsync(null); } if (currentVisibility == PanelVisibilityState.Closed) { await OnDismissed.InvokeAsync(null); } StateHasChanged(); }; }
public void NotifyOnDismissed() { OnDismissed?.Invoke(this); }