Search results

Animation

29 Sep 2022 / 1 minute to read

The Animation library is used to perform animation effects on HTML elements by running a 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.html
index.tsx
Copied to clipboard
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { useEffect, useRef } from 'react';
import { Animation } from '@syncfusion/ej2-base';
function App() {
    let element1 = useRef();
    let element2 = useRef();
    useEffect(() => {
        let animation = new Animation({ name: 'FadeIn', duration: 5000 });
        animation.animate(element1, { name: 'FadeOut' });
        animation.animate(element2, { name: 'ZoomOut' });
    }, []);
    return (<div id="container">
      <div id="element1" ref={(ele) => { element1 = ele; }}></div>
      <div id="element2" ref={(ele) => { element2 = ele; }}></div>
    </div>);
}
export default App;
ReactDom.render(<App />, document.getElementById('sample'));
Copied to clipboard
<!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/20.3.47/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/20.3.47/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>
Copied to clipboard
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { useEffect, useRef } from 'react';
import {useRef } from 'react';
import { Animation } from '@syncfusion/ej2-base';

function App() {
  let element1 = useRef();
  let element2 = useRef();
  useEffect(() => {
    let animation: Animation = new Animation({ name: 'FadeIn', duration: 5000 });
    animation.animate(element1, { name: 'FadeOut' });
    animation.animate(element2, { name: 'ZoomOut' });
  },[])

  return (
    <div id="container">
      <div id="element1" ref={(ele) => { element1 = ele; }}></div>
      <div id="element2" ref={(ele) => { element2 = ele; }}></div>
    </div>
  );
}
export default App;
ReactDom.render(<App />, document.getElementById('sample'));