Search results

Animations

The toast control supports custom animations for both shows and hide actions from the provided animation option of the Animation library.

The default animation is given as FadeIn for showing the toast and FadeOut for hiding the toast.

The following sample demonstrates some types of animations that suit toast. You can check all the animation effects here.

Source
Preview
index.js
index.html
ej.base.enableRipple(true);

//Initialize Toast component
var toast = new ej.notifications.Toast({
    title: 'Matt sent you a friend request',
    content: 'You have a new friend request yet to accept',
    target: document.body,
    position: { X: 'Right', Y: 'Bottom' }
});

//Render initialized Toast component
toast.appendTo('#element');

var listObjExpand = new ej.dropdowns.DropDownList({
    index: 0,
    placeholder: 'Select a animate type',
    change: () => { valueChange();  }
});
listObjExpand.appendTo('#showAnimation');

var listObjCollapse = new ej.dropdowns.DropDownList({
    placeholder: 'Select a animate type',
    change: () => { valueChange1();  }
});
listObjCollapse.appendTo('#hideAnimation');

document.getElementById('show_toast').onclick = function () {
    toast.show();
}

function valueChange() {
  toast.animation.show.effect = (listObjExpand.value);
}

function valueChange1() {
  toast.animation.hide.effect = (listObjCollapse.value);
}
toast.show();
<!DOCTYPE html><html lang="en"><head>
    <title>Essential JS 2 Toast</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript Toolbar Controls">
    <meta name="author" content="Syncfusion">
    <link href="//cdn.syncfusion.com/ej2/material.css" rel="stylesheet">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link href="index.css" rel="stylesheet">
    
    
<script src="https://cdn.syncfusion.com/ej2/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    
    <div id="container">
        <div id="default" style="padding-bottom:75px; width: 35%;">
            <div class="row">
                <div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
                    <label> Show Animation </label>
                </div>
                <div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
                    <select id="showAnimation">
                        <option value="FadeIn">Fade In</option>
                        <option value="FadeZoomIn">Fade Zoom In</option>
                        <option value="FadeZoomOut">Fade Zoom Out</option>
                        <option value="FlipLeftDownIn">Flip Left Down In</option>
                        <option value="FlipLeftDownOut">Flip Left Down Out</option>
                        <option value="FlipLeftUpIn">Flip Left Up In</option>
                        <option value="FlipLeftUpOut">Flip Left Up Out</option>
                        <option value="FlipRightDownIn">Flip Right Down In</option>
                        <option value="FlipRightDownOut">Flip Right Down Out</option>
                        <option value="FlipRightUpIn">Flip Right Up In</option>
                        <option value="FlipRightUpOut">Flip Right Up Out</option>
                        <option value="SlideBottomIn">Slide Bottom In</option>
                        <option value="SlideBottomOut">Slide Bottom Out</option>
                        <option value="SlideLeftIn">Slide Left In</option>
                        <option value="SlideLeftOut">Slide Left Out</option>
                        <option value="SlideRightIn">Slide Right In</option>
                        <option value="SlideRightOut">Slide Right Out</option>
                        <option value="SlideTopIn">Slide Top In</option>
                        <option value="SlideTopOut">Slide Top Out</option>
                        <option value="ZoomIn">Zoom In</option>
                        <option value="ZoomOut">Zoom Out</option>
                    </select>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
                    <label> Hide Animation </label>
                </div>
                <div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
                    <select id="hideAnimation">
                        <option value="FadeIn">Fade In</option>
                        <option value="FadeZoomIn">Fade Zoom In</option>
                        <option value="FadeZoomOut">Fade Zoom Out</option>
                        <option value="FlipLeftDownIn">Flip Left Down In</option>
                        <option value="FlipLeftDownOut">Flip Left Down Out</option>
                        <option value="FlipLeftUpIn">Flip Left Up In</option>
                        <option value="FlipLeftUpOut">Flip Left Up Out</option>
                        <option value="FlipRightDownIn">Flip Right Down In</option>
                        <option value="FlipRightDownOut">Flip Right Down Out</option>
                        <option value="FlipRightUpIn">Flip Right Up In</option>
                        <option value="FlipRightUpOut">Flip Right Up Out</option>
                        <option value="SlideBottomIn">Slide Bottom In</option>
                        <option value="SlideBottomOut">Slide Bottom Out</option>
                        <option value="SlideLeftIn">Slide Left In</option>
                        <option value="SlideLeftOut">Slide Left Out</option>
                        <option value="SlideRightIn">Slide Right In</option>
                        <option value="SlideRightOut">Slide Right Out</option>
                        <option value="SlideTopIn">Slide Top In</option>
                        <option value="SlideTopOut">Slide Top Out</option>
                        <option value="ZoomIn">Zoom In</option>
                        <option value="ZoomOut">Zoom Out</option>
                    </select>
                </div>
            </div>
            <div class="row"> <button class="e-btn" id="show_toast"> Show Toast</button> </div>
        </div>
        <div id="element"></div>
        <br>
        <br>
    </div>


<script>
var ele = document.getElementById('container');
if(ele) {
    ele.style.visibility = "visible";
 }   
        </script>
<script src="index.js" type="text/javascript"></script>
</body></html>