GithubHelp home page GithubHelp logo

nisheed2440 / ng2-amp-dash Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 3.0 39 KB

An Angular2 typing component

TypeScript 69.30% JavaScript 25.48% HTML 2.02% CSS 3.20%
angular4 npm-package aot-compatible amp-dash character types

ng2-amp-dash's Introduction

AMP DASH

npm version Build Status

amp-dash is an Angular 4 component that types. Enter in any string, and watch it type at the speed you've set, backspace what it's typed, and begin a new sentence for however many strings you've set.

amp-dash was inspired by the SapientRazorfish logo and created to be used to follow the brand guidelines.

Demo Page

NOTE: amp-dash has been updated to Angular 4, but can be used with Angular 2 as well, so long as the dependencies are satisfied


Installation

To begin start by running

npm install --save amp-dash

Next import into your app module

//app.module.ts

import { AmpDashModule } from 'amp-dash';
//Other imports

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    //Other Modules
    AmpDashModule // <-- amp-dash module
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

That's it! You are ready to use the amp-dash component.

Usage

Basic usage

<!-- app.component.html -->
<div class="app">
    <h1>
        <amp-dash [typeText]="'Hello World'"></amp-dash>
    </h1>
</div>

String Collections

You can provide string collections by passing an array to the typeText property.

The strings can new lines by providing the \n character.

<!-- app.component.html -->
<div class="app">
    <h1>
        <amp-dash 
            [typeText]="['Hello World','Foo Bar']"
        ></amp-dash>
        <!-- New line in strings -->
        <amp-dash 
            [typeText]="['Hello\nWorld','Foo\nBar']"
        ></amp-dash>
    </h1>
</div>

With type delay

You can provide a type delay i.e. the amount of time before the next character is printed by overriding the typeDelay property.

typeDelay is measured in milliseconds (ms).

<!-- app.component.html -->
<div class="app">
    <h1>
        <!-- Provide a 300ms type delay -->
        <amp-dash 
            [typeText]="'Hello World'"
            [typeDelay]="300"
        ></amp-dash>
    </h1>
</div>

With erase delay

You can provide an erase delay i.e. the amount of time before the displayed string is erased by overriding the eraseDelay property. eraseDelay is used in combination with typeLoop which loops over the collections of strings provided in the typeText.

eraseDelay is measured in milliseconds (ms).

<!-- app.component.html -->
<div class="app">
    <h1>
        <!-- Provide a 3000ms (3 second) erase delay -->
        <amp-dash 
            [typeText]="'Hello World'"
            [eraseDelay]="3000"
            [typeLoop]="true"
        ></amp-dash>
    </h1>
</div>

Updating the cursor

By default amp-dash comes the _ cursor character, which is animated by the class cursor. In order to update the character and to style it differently you can use the cursorChar & cursorClass properties.

<!-- app.component.html -->
<div class="app">
    <h1>
        <!-- Change the cursor character to `|` and class to `blinky-cursor` -->
        <amp-dash 
            [typeText]="'Hello World'"
            [cursorChar]="'|'"
            [cursorClass]="'blinky-cursor'"
        ></amp-dash>
    </h1>
</div>

Handling callbacks

You can handle the events like:

captionTyped triggered when each string has finished being displayed on the screen.

Or

captionErased triggered when each string has finished being erased from the screen.

<!-- app.component.html -->
<div class="app">
    <h1>
        <amp-dash 
            [typeText]="['Hello World','Foo Bar']"
            (captionTyped)="handleTyped($event)" 
            (captionErased)="handleErased($event)" 
        ></amp-dash>
    </h1>
</div>

Component Properties

Property Type Default Value Description
typeText `string array` ['']
typeDelay number 100 Delay in ms before a character is printed
eraseDelay number 2000 Delay in ms before the displayed string is erased
typeLoop boolean false Loop over the string collection
cursorClass string cursor Class name applied to the cursor character
cursorChar string _ The cursor character to be displayed by default
captionTyped function Event fired when each string has finished being displayed on the screen
captionErased function Event fired when each string has finished being erased from the screen

ng2-amp-dash's People

Contributors

angular-cli avatar nisheed2440 avatar nisheedj avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

ng2-amp-dash's Issues

Getting XHR error (404 Not Found) loading http://localhost:3000/amp-dash

Hi,
I'm trying to import amp-dash module in my app.module.ts file.When I inject it in my app.module.ts file like the one below

@NgModule({
    declarations: [AppComponent, HeaderAppComponent, GitUsers, HttpComponent, FooterComponent],
    imports: [BrowserModule, HttpModule, AmpDashModule],
    providers: [],
    bootstrap: [AppComponent, HeaderAppComponent, GitUsers, HttpComponent, FooterComponent]
})

getting an error in console and nothing loads in browser. Please let me know where I'm doing wrong.Code link https://github.com/mailmrmanoj/angular-graphql-integration
amp-dash-error

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.