Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

ng-character-select-carousel

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-character-select-carousel

Angular character select carousel for 3 characters.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

NgCharacterSelectCarouselModule

  • A spinning character select carousel supporting 3 characters. Powered by gsap.
  • Library location: projects/ng-character-select-carousel directory of this repository.

Example carousel

Examples/Demo

  • An example can be found under src/app directory of this repository.

Installation

npm i ng-character-select-carousel

API

import {NgCharacterSelectCarouselModule} from 'ng-character-select-carousel';
selector: ng-character-select-carousel

@Inputs()

InputTypeRequiredDescription
image1UrlstringOptional, default: sample imageUrl to character 1 image. If blank a sample image is used
image1MaskUrlstringOptional, default: sample imageUrl to character 1 image mask . If blank a sample image is used
image2UrlstringOptional, default: sample imageUrl to character 2 image. If blank a sample image is used
image2MaskUrlstringOptional, default: sample imageUrl to character 2 image mask . If blank a sample image is used
image2UrlstringOptional, default: sample imageUrl to character 3 image. If blank a sample image is used
image2MaskUrlstringOptional, default: sample imageUrl to character 3 image mask . If blank a sample image is used
spinsObservableOptionalFor submitting left/right spin events.

@Outputs()

OutputTypeRequiredDescription
selectedAvatarnumberNoemits the index of the selected character

Usage

  • Register the NgxMatTypeaheadModule in your app module.

import {NgCharacterSelectCarouselModule} from 'ng-character-select-carousel';

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import {NgCharacterSelectCarouselModule} from 'ng-character-select-carousel';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgCharacterSelectCarouselModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  • Use the NgCharacterSelectCarouselComponent in your component.
import {Component} from '@angular/core';
import {Subject} from 'rxjs';
import {Direction} from 'ng-character-select-carousel';

@Component({
  selector: 'app-root',
  template: `
      <div class="page">
        <div>
          <button (click)="left()">Left</button>
          <span>{{selectedAvatar}}</span>
          <button (click)="right()">Right</button>
        </div>
        <ng-character-select-carousel
            [spins]="eventsSubject.asObservable()"
            (selectedAvatar)="onSelectedAvatar($event)">
        </ng-character-select-carousel>        
      </div>
  `,
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'character-select-carousel';

  public selectedAvatar: number;

  eventsSubject: Subject<Direction> = new Subject<Direction>();

  public left() {
    this.eventsSubject.next(Direction.Left);
  }

  public right() {
    this.eventsSubject.next(Direction.Right);
  }

  public onSelectedAvatar(index: number) {
    this.selectedAvatar = index;
  }
}

Running the example in local env

  • npm i
  • Run ng serve for a dev server and running the demo app. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Build the component

Run ng build ng-character-select-carousel to build the library. The build artifacts will be stored in the dist/ng-character-select-carousel directory. Use the --prod flag for a production build.

Image masks

For each character image an image mask should be provided.

This is an image that follows the outline of the character image with a white background.

This ensures there is no transparency overlap as characters spin over each other.

For example:

Character image:

Character image example

Image mask:

Character image mask example

Credits

gsap is amazing!

Keywords

angular

FAQs

Package last updated on 23 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts