Example of Animation in ASP.NET MVC PredefinedDialogs Control
This example demonstrates how to show and hide the predefined dialog using a variety of animation effects. The dropdown item that displays the animation effects can be selected and set to it.
@Html.UiButton(new UiButtonOptions { Id = "confirmBtn", Text = "Confirm", Color = UiButtonColor.Success })
@Html.UiDropDownList("effects", new UiDropDownListOptions { Placeholder = "Animation effect", Width = "100%", PopupHeight = "220px", Value = "SlideTop", OnChange = "valueChange", Items = ((List<LayoutDemoController.PredefinedEffect>)ViewData["data"]).Select(e => new UiListItem(e.Id, e.Effect)).ToList() })
<style>
.control-section { padding: 25px 0 0 15px; min-height: 250px; }
.control-section #statusText { display: block; font-size: 16px; margin-top: 20px; }
.control-section .ui-btn { margin-right: 5px; }
#animationDrop { margin-top: 15px; max-width: 260px; }
</style>
@using Lumen.UI.Mvc.Demo.Controllers
<div class="control-section" id="predefinedDialogAnimation">
@Html.UiButton(new UiButtonOptions { Id = "confirmBtn", Text = "Confirm", Color = UiButtonColor.Success })
</div>
<div class="demo-property-panel property-section" title="Properties">
<div id="animationDrop">
@Html.UiDropDownList("effects", new UiDropDownListOptions { Placeholder = "Animation effect", Width = "100%", PopupHeight = "220px", Value = "SlideTop", OnChange = "valueChange", Items = ((List<LayoutDemoController.PredefinedEffect>)ViewData["data"]).Select(e => new UiListItem(e.Id, e.Effect)).ToList() })
</div>
</div>
<script>
// Syncfusion: the list sets the animation effect of the confirm dialog
var effect = 'SlideTop';
function valueChange(value) { if (value) { effect = value; } }
document.addEventListener('click', function (e) {
if (e.target.closest('#confirmBtn')) {
window.Lumen.confirm({ title: ' Delete Multiple Items', content: 'Are you sure you want to permanently delete these items?', animation: effect, width: '420px' });
}
});
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class PredefinedDialogsController : Controller
{
// The page is Views/PredefinedDialogs/Animation.cshtml; it draws what ViewData holds.
public ActionResult Animation()
{
ViewData["data"] = new List<PredefinedEffect>
{
new PredefinedEffect { Id = "FadeZoom", Effect = "Fade zoom" },
new PredefinedEffect { Id = "SlideBottom", Effect = "Slide bottom" },
new PredefinedEffect { Id = "SlideTop", Effect = "Slide top" },
new PredefinedEffect { Id = "Zoom", Effect = "Zoom" },
new PredefinedEffect { Id = "Fade", Effect = "Fade" }
};
return View();
}
/// <summary>An animation effect of the Predefined Dialogs sample's list.</summary>
public class PredefinedEffect
{
public string Id { get; set; }
public string Effect { get; set; }
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
The dialog can be opened or closed with an animation effect using the animationSettings property. You can also customize the duration of the animation and delay to begin the animation or disable the dialog's animation by setting the animation effect as none.
See also