Giter Club home page Giter Club logo

txtanime.js's Introduction

TxtAnime.js

It is a JavaScript library, which contains many beautiful and free text effects.



Installation


npm

npm install txtanime.js --save
// ES 2015
import { TxtAnime } from "txtanime.js";

// CommenJs
const { TxtAnime } = require('txtanime.js');

CDN

<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/mohamedfrindi/TxtAnime.js/dist/TxtAnime.js"></script>

Put the JS file at the end of the body tag:
<script type="text/javascript" src="dist/TxtAnime.js"></script>
<!-- or -->
<script type="text/javascript" src="dist/TxtAnime-min.js"></script>

Add the element you want to apply the effect to
<body>

    <!-- In case you want to implement txt.animate() -->
    <h2 class="element">Animation</h2>

    <!-- In case you want to implement txt.scale() -->
    <div class="txt"></div>

    <!-- In case you want to implement txt.overlay() -->
    <h2 class="overlay">Animation</h2>

    <!-- In case you want to implement txt.typed() -->
    <div class="typed"></div>

</body>


<script type="text/javascript" src="dist/TxtAnime-min.js"></script>
<script>

    let txt = new TxtAnime()

    txt.animate('.element' , {
        // options
    })
    // or 
    txt.scale('.txt' , {
        // options
    })
    // or 
    txt.overlay('.overlay' , {
        // options
    })
    // or 
    txt.typed('.typed' , {
        // options
    })

</script>

To run TxtAnime.Js just add the following code in your script:
let txt = new TxtAnime()


txt.animate('.element' , {
    // options
})
// or
txt.scale('.element' , {
    // opions
})
// or
txt.overlay('.element' , {
    // opions
})
// or 
txt.typed('.element' , {
    // opions
})


Options

txt.animate('element',{

    // selector element
    // Accepts a string or selector element
    // You can specify a class directly || txt.animate('.element // .elements')
    // Or you can add a javascript selector  || document.querySelector('.element') or document.querySelectorAll('.elements')


  effect : 'tx-an-1',
  // Select the effect you want
  // Accepts 10 options : tx-an-1 <== 1-10
  // default option : tx-an-1
  
  delayStart: 0,
  // Determining the start time of the effect
  // default option : 0
  // delayStart : 0s | second
  
  delay : 0.05,
  // Determine when to move between items
  // default option : 0.05
  // delay : 0.5s | second
  
  duration: 0.7,
  // Determine the speed of effect
  // default option : 0.7
  // duration : 0.7s | second
  
  loop : true,
  // To repeat the effect infinitely
  // accept 2 options : true | false
  // default option : true
  
  loopTime : 2,
  // Replay the effect after
  // default option : 2
  // loopTime : 2s | second
  
  overflow: true,
  // Makes masking effect inside parent element
  // Accepts 2 options : false / true
  // default option : true

});

// ----------------------------------------------------------------

txt.scale('element',{

    // selector element
    // Accepts a string or selector element
    // You can specify a class directly || txt.animate('.element // .elements')
    // Or you can add a javascript selector  || document.querySelector('.element') or document.querySelectorAll('.elements')


  text : ['Go' , 'To' , 'Site'],
  // The words you want to apply the effect to
  // default option : ['Go' , 'To' , 'Site']

  effect : 'scale-1',
  // Select the effect you want
  // currently Accepts 2 options : scale-1 | scale-2
  // default option : scale-1
  
  delayStart: 0,
  // Determining the start time of the effect
  // default option : 0
  // delayStart : 0s | second
  
  delay : 1.5,
  // Determine when to move between items
  // default option : 1.5
  // delay : 1.5s | second
  
  duration: 2,
  // Determine the speed of effect
  // default option : 2
  // duration : 2s | second
  
  loop : true,
  // To repeat the effect infinitely
  // accept 2 options : true | false
  // default option : true

});

// ----------------------------------------------------------------

txt.overlay('element',{

    // selector element
    // Accepts a string or selector element
    // You can specify a class directly || txt.animate('.element // .elements')
    // Or you can add a javascript selector  || document.querySelector('.element') or document.querySelectorAll('.elements')


  effect : 'overlay-1',
  // Select the effect you want
  // Accepts 3 options : overlay-1 | overlay-2 | overlay-3
  // default option : overlay-1
  
  delayStart: 0,
  // Determining the start time of the effect
  // default option : 0
  // delayStart : 0s | second
  
  loop : true,
  // To repeat the effect infinitely
  // accept 2 options : true | false
  // default option : true
  
  loopTime : 5,
  // Replay the effect after
  // default option : 5s
  // loopTime : 5s | second
  
  overlayColor: '#03a9f4',
  // add background color for overlay
  // default option : '#03a9f4'

  textColor : '#161414',
  // change text color
  // default option : '#161414'

  outTime: 3,
  // Waiting time for the exit effect to be applied
  // default option : 3
  // outTime : 3s | second

});

// ----------------------------------------------------------------

txt.typed('element',{

    // selector element
    // Accepts a string or selector element
    // You can specify a class directly || txt.animate('.element // .elements')
    // Or you can add a javascript selector  || document.querySelector('.element') or document.querySelectorAll('.elements')


  effect : 'typed-1',
  // Select the effect you want
  // Accepts 3 options : typed-1 | typed-2 | typed-3
  // default option : typed-1

  text : ['Typed for TxtAnime' , 'Try free' , 'JavaScript Plugin'],
  // The words you want to apply the effect to
  // default option : ['Typed for TxtAnime' , 'Try free' , 'JavaScript Plugin']

  typedStart: 0,
  // Determining the start time of the effect
  // default option : 0
  // delayStart : 0s | second
  
  loopTime : 3,
  // Replay the effect after
  // default option : 3s
  // loopTime : 3s | second

  typedSpeed : 0.05,
  // set speed typed
  // default option : 0.05

  outTime: 1,
  // Waiting time for the exit effect to be applied
  // default option : 1
  // outTime : 1s | second

});

txtanime.js's People

Contributors

mohamedfrindi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.