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

ngx-image-swiper

v1.2.3

Published

A relatively simple component for displaying images in a container that can be navigated by mouse, touch and keyboard with no dependencies, other than Angular of course.

Downloads

213

Readme

NgxImageSwiper

npm version

A relatively simple component for displaying images in a container that can be navigated by mouse, touch and keyboard events with no dependencies, other than Angular of course.

Stackblitz Demo

Installation

npm i ngx-image-swiper --save

Usage

Import NgImageSwiperModule into the required module:

import { NgImageSwiperModule } from 'ngx-image-swiper';

@NgModule({
  imports: [
    NgImageSwiperModule
  ]
})

In your component:

import { Component } from '@angular/core';
import { NgxSwiperConfig } from 'ngx-image-swiper';

@Component({
  selector: 'app-root',
  template: `
    <!-- put the component in a containing div -->
    <div class="image-swiper">
      <ngx-image-swiper [config]="swiperConfig" [images]="images"></ngx-image-swiper>
    </div>
  `,
  styles: [
    `
      // position must be relative
      // width & height can be whatever you want
      .image-swiper {
        position: relative;
        width: 600px;
        height: 600px;
      }
    `
  ]
})
export class AppComponent {
  swiperConfig: NgxSwiperConfig = {
    navigationPlacement: 'inside',
    pagination: true,
    paginationPlacement: 'outside'
  };

  images = [
    'https://images.pexels.com/photos/2387869/pexels-photo-2387869.jpeg',
    'https://images.pexels.com/photos/2395264/pexels-photo-2395264.jpeg',
    'https://images.pexels.com/photos/2474014/pexels-photo-2474014.jpeg',
    'https://images.pexels.com/photos/2440296/pexels-photo-2440296.jpeg',
    'https://images.pexels.com/photos/2506269/pexels-photo-2506269.jpeg'
  ];
}

Inputs & Configuration

The component comes with two inputs, config and images.

config

Here you can pass in the configuration options you want to change from their defaults (explained below).

images

The array of images to pass into the swiper component.

Configuration Options

Ngx-Image-Swiper comes with the following configuration options:

navigation?: boolean;
navigationPlacement?: 'inside' | 'outside';
navigationLeftIcon?: string;
navigationRightIcon?: string;
pagination?: boolean;
paginationPlacement?: 'inside' | 'outside';
imgBackgroundSize?: string;
border?: boolean;
borderRadius?: number;
swipeThreshold?: number;
loop?: boolean;
keyboardNavigation?: boolean;

navigation

Enable/disable left/right button navigation (will only show there is more than 1 image).

  • default: true

navigationPlacement

Where the navigation buttons should appear, outside the images or inside over the images.

  • default: 'outside'
  • available options: 'inside' | 'outside

navigationLeftIcon & navigationRightIcon

Overwrite the icons used for the background image of the left/right navigation buttons.


pagination

Enable/disable the pagination dots (will only show there is more than 1 image).

  • default: 'true'

paginationPlacement

Where the pagination dots should appear, outside the images or inside over the images.

  • default: 'outside'
  • available options: 'inside' | 'outside'

imgBackgroundSize

Sets the background-size CSS property on the images

  • default: 'cover'

border

Enable/disable a border around the images

  • default: 'true'

borderRadius

Sets the border radius on the images. border must be true also.

  • default: 4

swipeThreshold

Sets a distance threshold images must be dragged to go to the previous/next image otherwise it will remain on the current image.

  • default: '50'

loop

Enable/disable looping of the images.

  • default: 'true'

keyboardNavigation

Enable/disable capturing of the left/right arrow keys on the users keyboard to navigation the images.

  • default: 'true'

Event Outputs

There is just out output event, imageClick which is fired when the user clicks on any given image. It outputs the index number of the image.