0.0.6 • Published 3 years ago

ng-opengallery v0.0.6

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

Opengallery

Opengallery is an Angular library component for efficient gallery rendering and interactions (images & videos). The gallery layout is responsive for all devices and loads the content only if it's in the viewport. A media viewer is shipped and included with this library. You can configure the component the way you want.

Demo

Try it out here: DEMO or clone this repo and run ng serve for a full demo of opengallery. Built with angular version 9.

Features

  • Fast & efficient gallery rendering
  • Loads content when they enter the viewport
  • Supports video/image mixed in the gallery
  • Play/Pause the video when the enter/exit the viewport (some browser block autoplay)
  • Different layouts to choose from and customise the way you want it (simple, catalog, carousel, masonry)
  • Include a media viewer modal to click and view the media (diaporama support, keystroke support)
  • Automatically hides media when they cannot be loaded
  • Detect dynamically new changes in medias and adapt itself

How to use

First install the package with the command npm i ng-opengallery

Then, in your module.ts, import the library module

import { NgOpengalleryModule } from 'ng-opengallery';

And add it to your imports modules, then you can use it in any component.html

<ng-opengallery
    [datasource]='this.data'
    [config]='this.config'
    (change)='onChange($event)'
    (error)='onError($event)'
    (selection)='onSelection($event)'
    (open)='onOpen($event)'>
</ng-opengallery>

If you want a full code demo, check out the repository on github here

Inputs

PropertyTypeNote
datasourceArray(Media)Media datasource with data
configConfigConfiguration of the gallery (prefMediaHeight,spacing,layout,viewerEnabled,viewerFullsize,diaporamaDuration,enableAutoPlay)
config.prefMediaHeightnumberprefered height size of media in the layouts, default is 250
config.spacingnumberspacing between media, is not taken into account for the caroussel layout, default is 2
config.layoutLayoutStyleSpecify the media layout you want (SIMPLE, CATALOG, CAROUSEL, MASONRY), default is SIMPLE
config.viewerEnabledbooleanSpecify whether the modal viewer should appear when a media is clicked, default is true
config.viewerFullsizebooleanSpecify whether the media in the modal viewer should take the full width and height available, default is false
config.diaporamaDurationnumberDuration for the diaporama in the modal viewer, if 0 is specified, diaporama is disabled, default is 3
config.enableAutoPlaynumberSpecify if a media should start when it enters the viewport, default is true
config.effectClassstringSpecial effect applied on media defined by the user, if null no effect is applied, default is null

Outputs

EventTypeNote
(change)MediaEmits the current media when the diaporama changes automatically or by the user (carousel,media viewer)
(error)MediaEmits the media that caused an error (could not be loaded)
(selection)MediaEmits the media that was selected by the user
(open)booleanEmits a boolean when the media viewer is opened or closed

To-Do / Improvements

  • Move some logic in service and remove from components
  • Add Squared layout
  • Add animations support
  • Add Iframe support

NPM

This package is on npm https://www.npmjs.com/package/ng-opengallery

License

This package is under the MIT license