npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

elementary-slider

v1.0.1

Published

Elementary image slider for angular 2

Downloads

4

Readme

Elementary Slider

Installation

First of all, add elementary-uploader module as a dependency to your project:

npm install elementary-slider --save

Then include ElementarySliderModule.forRoot() and BrowserAnimationsModule into your main AppModule.

// app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ElementarySliderModule } from 'elementary-slider';

@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        ElementarySliderModule.forRoot(),
    ],
    declarations: [AppComponent],
})
export class AppModule {}

use ElementarySliderModule.forChild() into your SharedModule. This could be usefull if your project has nested Modules.

// shared.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ElementarySliderModule } from 'elementary-slider';
...
 
@NgModule({
  imports: [
    CommonModule,
    ElementarySliderModule.forChild(),
    ...
  ],
  exports: [
    CommonModule,
    ElementarySliderModule.forChild(),
    ...
  ],
  ...
})
export class SharedModule {}

Inputs

@Input() config: SliderConfig; // main config
@Input() images?: string[]; // optional images, if you want set images in template

Outputs

@Output() changeSlideIndex; // emitted when index slide changes

Config

  • Types and Interfaces:
export type SliderConfig = {
    images?: string[]; // images url's
    backgroundColor?: string; // background color under images
    width?: IWidth;
    animationParams?: Partial<IAnimationParams>; 
    delay?: number; // if you set delay, slides will be changing automatically after set value (seconds)
    swiping?: boolean; // need install hammerjs
    loop?: boolean;
    withArrow?: boolean;
}

interface IWidth {
    value: number;
    unit: UnitTypes;
}

interface IAnimationParams {
    animationDuration: number;
    animationType: AnimationType;
}
  • Default config (if you do not specify any parameter, it will be equal to the default value):
    images = [''];
    width = { value: 1024, unit: UnitTypes.Pixel };
    backgroundColor = 'transparent';
    animationParams = { animationDuration: 200, animationType: AnimationType.Slide };
  • AnimationTypes it is enum and it can be Slide or Fade.
  • UnitTypes it is enum and it can be Pixel or Percent.

WARNING

If you choose swiping === true, you would install hammerjs and add polyfills:

npm install hammerjs --save
// polyfills.ts

/***************************************************************************************************
 * Zone JS is required by default for Angular itself.
 */
import 'zone.js/dist/zone';  // Included with Angular CLI.
import 'hammerjs';

#Example Component Code

import { Component } from '@angular/core';
import { SliderConfig } from 'elementary-slider';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css'],
})
export class AppComponent {
    config: SliderConfig = {
        images: [
            'assets/slide_1.jpg',
            'assets/slide_2.jpg',
            'assets/slide_3.jpg',
            'assets/slide_4.jpg',
            'assets/slide_5.jpg',
        ],
        withArrow: true,
        loop: true,
    };
}

Template Code

<elementary-slider [config]="config"></elementary-slider>