Search results

Animation

The Animation library is used to perform animation effects on HTML elements by running sequence of frames.

Animate HTML Element

The animate method of Animation library can be used to animate the HTML elements. This method can also take additional AnimationModel. Refer the following code snippet to animate a multiple DOM element

Source
Preview
index.jsx
index.tsx
index.html
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { Animation } from '@syncfusion/ej2-base';
class App extends React.Component {
    componentDidMount() {
        let animation = new Animation({ name: 'FadeIn', duration: 5000 });
        animation.animate(this.element1, { name: 'FadeOut' });
        animation.animate(this.element2, { name: 'ZoomOut' });
    }
    render() {
        return (<div id="container">
             <div id="element1" ref={(ele) => { this.element1 = ele; }}></div>
             <div id="element2" ref={(ele) => { this.element2 = ele; }}></div>
            </div>);
    }
}
ReactDom.render(<App />, document.getElementById('sample'));
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { Animation } from '@syncfusion/ej2-base';

class App extends React.Component<{}, {}> {
    public componentDidMount(): void {
      let animation: Animation = new Animation({ name: 'FadeIn', duration: 5000 });
      animation.animate(this.element1, { name: 'FadeOut' });
      animation.animate(this.element2, { name: 'ZoomOut' });
    }

    render() {
        return (
            <div id="container">
             <div id="element1" ref={(ele) => { this.element1 = ele; }}></div>
             <div id="element2" ref={(ele) => { this.element2 = ele; }}></div>
            </div>
    );
  }
}
ReactDom.render(<App />, document.getElementById('sample'));
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Button</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="index.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-react-buttons/styles/material.css" rel="stylesheet" />
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
        <div id='sample'>
            <div id='loader'>Loading....</div>
        </div>
</body>

</html>