Spinner
Change spinner position
Spinner position can be changed by modifying the Position
property of SpinSettings
. By default, the spinner is positioned at the left of the ProgressButton. You can position it at the left
, right
, top
, bottom
, or center
of the text content.
Change spinner size
Spinner size can be changed by modifying the Width
property of SpinSettings
. In this demo, the Width
is set to 20
to change the spinner size.
Spinner template
You can use custom spinner by specifying the Template
property of SpinSettings
with custom styles.
The following sample demonstrates the above functionalities of the spinner.
@Html.EJS().ProgressButton("submit").Content("Submit").SpinSettings(ViewBag.spinSettings).Render()
<style>
@@keyframes custom-rolling {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.template {
border: 2px solid green;
border-style: dotted;
border-radius: 50%;
border-top-color: transparent;
border-bottom-color: transparent;
height: 16px;
width: 16px;
}
.template {
-webkit-animation: custom-rolling 1.3s linear infinite;
animation: custom-rolling 1.3s linear infinite;
}
</style>
public class HomeController : Controller
{
public ActionResult Index()
{
ProgressButtonSpinSettings spinSettings = new ProgressButtonSpinSettings()
{
Position = SpinPosition.Right,
Width = "20",
Template = "<div class='template'></div>"
};
ViewBag.spinSettings = spinSettings;
return View();
}
}
Progress
Content animation
The Content
of the ProgressButton can be animated during progress using the Effect
property of AnimationSettings
. You can also set custom duration and timing function using the duration
and easing
properties. The possible effect
values are None
, SlideLeft
, SlideRight
, SlideUp
, SlideDown
, ZoomIn
, and ZoomOut
.
@Html.EJS().ProgressButton("slideleft").Content("Slide Left").EnableProgress(true).AnimationSettings(ViewBag.animationSettings).SpinSettings(ViewBag.spinSettings).Render()
using Syncfusion.EJ2.SplitButtons;
public class HomeController : Controller
{
public ActionResult Index()
{
ProgressButtonSpinSettings spinSettings = new ProgressButtonSpinSettings()
{
Position = SpinPosition.Left
};
ViewBag.spinSettings = spinSettings;
ProgressButtonAnimationSettings animationSettings = new ProgressButtonAnimationSettings()
{
Effect = AnimationEffect.SlideRight,
Duration = 500,
Easing = "linear",
};
ViewBag.animationSettings = animationSettings;
return View();
}
}
Change step of the ProgressButton
The progress state can be visualized to the specified interval by changing the Step
property in the begin
event of the ProgressButton. In this demo, the Step
property is set to 20
to show progress at every 20% increment.
@Html.EJS().ProgressButton("progress").Content("Progress Step").EnableProgress(true).Begin("begin").CssClass("e-hide-spinner").Render()
<script>
function begin(args) {
args.step = 20;
}
</script>
public ActionResult Default()
{
return View();
}
NOTE
The class
e-hide-spinner
hides the spinner in the ProgressButton, For more information, see hide spinner section
Changing progress state dynamically
The progress state can be changed dynamically by modifying the Percent
property in the progress events. In this demo, on 40% completion of progress, the Percent
property is set to 90
to show dynamic change of the progress state.
@Html.EJS().ProgressButton("progress").Content("Progress").EnableProgress(true).Duration(15000).Begin("begin").Progress("progress").End("end").CssClass("e-hide-spinner").Render()
<script>
function begin(args) {
this.content = 'Progress ' + args.percent + '%';
this.dataBind();
}
function progress(args) {
this.content = 'Progress ' + args.percent + '%';
this.dataBind();
if (args.percent === 40) {
args.percent = 90
}
}
function end(args) {
this.content = 'Progress ' + args.percent + '%';
this.dataBind();
}
</script>
public ActionResult Default()
{
return View();
}
NOTE
The method
dataBind
applies the property changes immediately to the component.
Start and stop methods
You can pause and resume the progress using the stop
and start
methods, respectively. In this demo, clicking the ProgressButton will pause and resume the progress.
@Html.EJS().ProgressButton("download").Content("Download").EnableProgress(true).IconCss("e-btn-sb-icon e-download").Duration(4000).Created("created").End("end").CssClass("e-hide-spinner").Render()
<script>
function end() {
var progressBtn = ej.base.getComponent(document.querySelector("#download"), "progress-btn");
progressBtn.content = 'Download';
progressBtn.iconCss = 'e-btn-sb-icon e-download';
progressBtn.dataBind();
}
function created() {
var progressBtn = ej.base.getComponent(document.querySelector("#download"), "progress-btn");
progressBtn.element.addEventListener('click', clickHandler);
}
function clickHandler() {
var progressBtn = ej.base.getComponent(document.querySelector("#download"), "progress-btn");
if (progressBtn.content === 'Download') {
progressBtn.content = 'Pause';
progressBtn.iconCss = 'e-btn-sb-icon e-pause';
progressBtn.dataBind();
}
// clicking on ProgressButton will stop the progress when the text content is 'Pause'
else if (progressBtn.content === 'Pause') {
progressBtn.content = 'Resume';
progressBtn.iconCss = 'e-btn-sb-icon e-play';
progressBtn.dataBind();
progressBtn.stop();
}
// clicking on ProgressButton will start the progress when the text content is 'Resume'
else if (progressBtn.content === 'Resume') {
progressBtn.content = 'Pause';
progressBtn.iconCss = 'e-btn-sb-icon e-pause';
progressBtn.dataBind();
progressBtn.start();
}
}
</script>
<style>
@@font-face {
font-family: 'btn-icon';
src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAAKAIAAAwAgT1MvMj1tSfgAAAEoAAAAVmNtYXDnH+dzAAABoAAAAEJnbHlm1v48pAAAAfgAAAQYaGVhZBOPfZcAAADQAAAANmhoZWEIUQQJAAAArAAAACRobXR4IAAAAAAAAYAAAAAgbG9jYQN6ApQAAAHkAAAAEm1heHABFQCqAAABCAAAACBuYW1l07lFxAAABhAAAAIxcG9zdK9uovoAAAhEAAAAgAABAAAEAAAAAFwEAAAAAAAD9AABAAAAAAAAAAAAAAAAAAAACAABAAAAAQAAJ1LUzF8PPPUACwQAAAAAANg+nFMAAAAA2D6cUwAAAAAD9AP0AAAACAACAAAAAAAAAAEAAAAIAJ4AAwAAAAAAAgAAAAoACgAAAP8AAAAAAAAAAQQAAZAABQAAAokCzAAAAI8CiQLMAAAB6wAyAQgAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABA5wDnBgQAAAAAXAQAAAAAAAABAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAACAAAAAwAAABQAAwABAAAAFAAEAC4AAAAEAAQAAQAA5wb//wAA5wD//wAAAAEABAAAAAEAAgADAAQABQAGAAcAAAAAAAAADgAkADIAhAEuAewCDAAAAAEAAAAAA2ED9AACAAA3CQGeAsT9PAwB9AH0AAACAAAAAAPHA/QAAwAHAAAlIREhASERIQJpAV7+ov3QAV7+ogwD6PwYA+gAAAEAAAAAA4sD9AACAAATARF0Ax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rZS0tLTAxBGNvcHkQLWRvd25sb2FkLTAyLXdmLQAA) format('truetype');
font-weight: normal;
font-style: normal;
}
.e-btn-sb-icon {
font-family: 'btn-icon' !important;
speak: none;
font-size: 55px;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.e-download::before {
content: '\e706';
}
.e-play::before {
content: '\e700';
}
.e-pause::before {
content: '\e701';
}
</style>
public ActionResult Default()
{
return View();
}