Socket
Socket
Sign inDemoInstall

@kolkov/ngx-gallery

Package Overview
Dependencies
6
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @kolkov/ngx-gallery

A simple responsive native gallery component for Angular 8+ and 13+.


Version published
Weekly downloads
7.3K
decreased by-18.81%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

NgxGallery

A simple native gallery component for Angular 8+ and 13+.

npm version demo Build Status npm Coverage Status dependencies Status devDependencies Status codecov Donate

Demo

Demo is here demo

Working code for this demo at stackblitz example

Getting Started

Installation

Install via npm package manager

npm install @kolkov/ngx-gallery --save

Versions

2.x.x and above - for Angular v13+ 1.x.x and above - for Angular v8+

Usage

Import ngx-gallery module

import { HttpClientModule} from '@angular/common/http';
import { NgxGalleryModule } from '@kolkov/ngx-gallery';

@NgModule({
  imports: [ HttpClientModule, NgxGalleryModule ]
})

Then in HTML

<ngx-gallery [options]="galleryOptions" [images]="galleryImages" class="ngx-gallery"></ngx-gallery>

where

import {Component, OnInit} from '@angular/core';
import {NgxGalleryOptions} from '@kolkov/ngx-gallery';
import {NgxGalleryImage} from '@kolkov/ngx-gallery';
import {NgxGalleryAnimation} from '@kolkov/ngx-gallery';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit{
  galleryOptions: NgxGalleryOptions[];
  galleryImages: NgxGalleryImage[];

  constructor() { }

  ngOnInit() {
    this.galleryOptions = [
      {
        width: '600px',
        height: '400px',
        thumbnailsColumns: 4,
        imageAnimation: NgxGalleryAnimation.Slide
      },
      // max-width 800
      {
        breakpoint: 800,
        width: '100%',
        height: '600px',
        imagePercent: 80,
        thumbnailsPercent: 20,
        thumbnailsMargin: 20,
        thumbnailMargin: 20
      },
      // max-width 400
      {
        breakpoint: 400,
        preview: false
      }
    ];

    this.galleryImages = [
      {
        small: 'assets/img/gallery/1-small.jpeg',
        medium: 'assets/img/gallery/1-medium.jpeg',
        big: 'assets/img/gallery/1-big.jpeg'
      },
      {
        small: 'assets/img/gallery/2-small.jpeg',
        medium: 'assets/img/gallery/2-medium.jpeg',
        big: 'assets/img/gallery/2-big.jpeg'
      },
      {
        small: 'assets/img/gallery/3-small.jpeg',
        medium: 'assets/img/gallery/3-medium.jpeg',
        big: 'assets/img/gallery/3-big.jpeg'
      },{
        small: 'assets/img/gallery/4-small.jpeg',
        medium: 'assets/img/gallery/4-medium.jpeg',
        big: 'assets/img/gallery/4-big.jpeg'
      },
      {
        small: 'assets/img/gallery/5-small.jpeg',
        medium: 'assets/img/gallery/5-medium.jpeg',
        big: 'assets/img/gallery/5-big.jpeg'
      }
    ];
  }
}

add this class to app CSS .ngx-gallery { display: inline-block; margin-bottom: 20px; }

API

Inputs

InputTypeDefaultRequiredDescription
[options]NgxGalleryOptions[]-noConfig options for the Gallery
[images]NgxGalleryImage[]-noImages array

Outputs

OutputDescription
(change)Triggered on image change
(imagesReady)Triggered when images length > 0
(previewOpen)Triggered on preview open
(previewClose)Triggered on preview close
(previewChange)Triggered on preview image change

Methods

NameDescription
show(index: number): voidShows image at index
showNext(): voidShows next image
showPrev(): voidShows prev image
canShowNext(): booleanReturns true if there is next image
canShowPrev(): booleanReturns true if there is prev image
openPreview(index: number): voidOpens preview at index
moveThumbnailsLeft(): voidMoves thumbnails to left
moveThumbnailsRight(): voidMoves thumbnails to right
canMoveThumbnailsLeft(): booleanReturns true if you can move thumbnails to left
canMoveThumbnailsRight(): booleanReturns true if you can move thumbnails to right

NgxGalleryOptions

Layout options
InputTypeDefaultRequiredDescription
widthstring500pxnoGallery width
heightstring400pxnoGallery height
breakpointnumberundefinednoResponsive breakpoint, works like media query max-width
fullWidthboleanfalsenoSets the same width as browser
layoutstringNgxGalleryLayout.BottomnoSets thumbnails position
startIndexnumber0noSets index of selected image on start
linkTargetstring_blanknoSets target attribute of link
lazyLoadingbooleantruenoEnables/disables lazy loading for images
Image options
InputTypeDefaultRequiredDescription
imagebooleantruenoEnables or disables image
imageDescriptionbooleantruenoEnables or disables description for images
imagePercentnumber75noPercentage height
imageArrowsbooleantruenoEnables or disables arrows
imageArrowsAutoHidebooleanfalsenoEnables or disables arrows auto hide
imageSwipebooleanfalsenoEnables or disables swipe
imageAnimationstringNgxGalleryAnimation.FadenoAnimation type
imageSizestringNgxGalleryImageSize.CovernoImage size
imageAutoPlaybooleanfalsenoEnables or disables auto play
imageAutoPlayIntervalnumber2000noInterval for auto play (ms)
imageAutoPlayPauseOnHoverbooleanfalsenoEnables or disables pause auto play on hover
imageInfinityMovebooleanfalsenoEnables or disables infinity move by arrows
imageActionsNgxGalleryAction[][]noEnables or disables navigation bullets
Thumbnails options
InputTypeDefaultRequiredDescription
thumbnailsbooleantruenoEnables or disables thumbnails
thumbnailsColumnsnumber4noColumns count
thumbnailsRowsnumber1noRows count
thumbnailsPercentnumber25noPercentage height
thumbnailsMarginnumber10noMargin between thumbnails and image
thumbnailsArrowsbooleantruenoEnables or disables arrows
thumbnailsArrowsAutoHidebooleanfalsenoEnables or disables arrows auto hide
thumbnailsSwipebooleanfalsenoEnables or disables swipe
thumbnailsMoveSizenumber1noNumber of items to move on arrow click
thumbnailsOrdernumberNgxGalleryOrder.ColumnnoImages order
thumbnailsRemainingCountbooleanfalsenoIf true arrows are disabled and last item has label with remaining count
thumbnailsAsLinksbooleanfalsenoEnables or disables links on thumbnails
thumbnailsAutoHidebooleanfalsenoHides thumbnails if there is only one image
thumbnailMarginnumber10noMargin between images in thumbnails
thumbnailSizestringNgxGalleryImageSize.CovernoThumbnail size
thumbnailActionsNgxGalleryAction[][]noArray of custom actions
thumbnailClassesstring[][]noCustom classes to add to thumbnail component
Preview options
InputTypeDefaultRequiredDescription
previewbooleantruenoEnables or disables preview
previewDescriptionbooleantruenoEnables or disables description for images
previewArrowsbooleantruenoEnables or disables arrows
previewArrowsAutoHideboolean: stringfalsenoEnables or disables arrows auto hide
previewSwipebooleanfalsenoEnables or disables swipe
previewFullscreenbooleanfalsenoEnables or disables fullscreen icon
previewForceFullscreenbooleanfalsenoEnables or disables opening preview in fullscreen mode
previewCloseOnClickbooleanfalsenoEnables or disables closing preview by click
previewCloseOnEscbooleanfalsenoEnables or disables closing preview by esc keyboard
previewKeyboardNavigationbooleanfalsenoEnables or disables navigation by keyboard
previewAnimationbooleantruenoEnables or disables image loading animation
previewAutoPlaybooleanfalsenoEnables or disables auto play
previewAutoPlayIntervalnumber2000noInterval for auto play (ms)
previewAutoPlayPauseOnHoverbooleanfalsenoEnables or disables pouse auto play on hover
previewInfinityMovebooleanfalsenoEnables or disables infinity move by arrows
previewZoombooleanfalsenoEnables or disables zoom in and zoom out
previewZoomStepnumber0.1noStep for zoom change
previewZoomMaxnumber2noMax value for zoom
previewZoomMinnumber0.5noMin value for zoom
previewRotatebooleanfalsenoEnables or disables rotate buttons
previewDownloadbooleanfalsenoEnables or disables download button
previewBulletsbooleanfalsenoEnables or disables navigation bullets
Icons options
InputTypeDefaultRequiredDescription
arrowPrevIconstring'fa fa-arrow-circle-left'noIcon for prev arrow
arrowNextIconstring'fa fa-arrow-circle-right'noIcon for next arrow
closeIconstring'fa fa-times-circle'noIcon for close button
fullscreenIconstring'fa fa-arrows-alt'noIcon for fullscreen button
spinnerIconstring'fa fa-spinner fa-pulse fa-3x fa-fw'noIcon for spinner
zoomInIconstring'fa fa-search-plus'noIcon for zoom in
zoomOutIconstring'fa fa-search-minus'noIcon for zoom out
rotateLeftIconstring'fa fa-undo'noIcon for rotate left
rotateRightIconstring'fa fa-repeat'noIcon for rotate right
downloadIconstring'fa fa-arrow-circle-down'noIcon for download
actionsNgxGalleryAction[][]noArray of new custom actions that will be added to the left of the current close/zoom/fullscreen icons

NgxGalleryImage

InputTypeDefaultRequiredDescription
smallstring/SafeResourceUrl-noUrl used in thumbnails
mediumstring/SafeResourceUrl-noUrl used in image
bigstring/SafeResourceUrl-yesUrl used in preview
descriptionstring-noDescription used in preview
urlstring-noUrl used in link
labelstring-noLabel used for aria-label when thumbnail is a link

NgxGalleryAnimation

  • Fade (default)
  • Slide
  • Rotate
  • Zoom

NgxGalleryImageSize

  • Cover (default)
  • Contain

NgxGalleryLayout

  • Top
  • Bottom (default)

NgxGalleryOrder

  • Column (default)
  • Row
  • Page

NgxGalleryAction

  • icon | Type: string - icon for custom action
  • disabled | Type: boolean | Default value: false - if the icon should be disabled
  • titleText | Type: string | Default value: '' - text to set the title attribute to
  • onClick | Type: (event: Event, index: number) => void - Output function to call when custom action icon is clicked

What's included

Within the download you'll find the following directories and files. You'll see something like this:

ngx-gallery/
└── projects/
    ├── gallery/
    └── gallery-app/

gallery/ - library

gallery-app/ - demo application

Contributing

Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.

Editor preferences are available in the editor config for easy use in common text editors. Read more and download plugins at http://editorconfig.org.

Versioning

For transparency into our release cycle and in striving to maintain backward compatibility, NgxGallery is maintained under the Semantic Versioning guidelines.

See the Releases section of our project for changelogs for each release version.

Creators

Andrey Kolkov

Credits

This library is being fully rewritten for next Angular versions from original abandoned library written by Łukasz Gałka. I maintained full compatibility with the original library at the api level. https://github.com/lukasz-galka/ngx-gallery

Donate

If you like my work, and I save your time you can buy me a :beer: or :pizza: Donate

Keywords

FAQs

Last updated on 28 Jan 2022

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc