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

@jaguards/ngx-viewer2

v16.2.12-rc1

Published

Angular 15+ directive for the Viewer.js library

Downloads

660

Readme

ngx-viewer2 :mag_right:

Latest Stable Version License Made by L.E.O.R

This is a simple Angular 15+ directive wrapping the amazing Viewer.js library.

Forked from winteragency/ngx-viewer

Installation

Add both this library and the original Viewer.js library as dependencies to your project:

npm install @jaguards/ngx-viewer2 viewerjs

Import the module into your application's app.module.ts:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

// import ngx-viewer module
import { NgxViewer2Module } from "@jaguards/ngx-viewer2";

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgxViewer2Module // add ngx-viewer module here
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Finally, you'll need to import the styles for Viewer.js somehow, for example in your base styles.(s)css:

@import '~viewerjs/dist/viewer.css';

Basic usage

The ngxViewer2 directive can be added to a container wrapping multiple images, or to an individual image. The default Viewer.js configuration options will be used.

Single image

<img src="https://picsum.photos/2000/1500" ngxViewer2>

Multiple images (gallery)

<div ngxViewer2>
  <img src="https://picsum.photos/2000/1500/?random=1" alt="Image 1">
  <img src="https://picsum.photos/2000/1500/?random=2" alt="Image 2">
  <img src="https://picsum.photos/2000/1500/?random=3" alt="Image 3">
</div>

Options

All options exposed by Viewer.js can be set for this directive using [viewerOptions]:

Template file (HTML)

<img src="https://picsum.photos/2000/1500" ngxViewer2 [viewerOptions]="viewerOptions">

Component file (TS)

public viewerOptions: any = {
  navbar: false,
  toolbar: {
    zoomIn: 4,
    zoomOut: 4,
    oneToOne: 4,
    reset: 4,
    prev: 4,
    play: {
      show: 4,
      size: 'large',
    },
    next: 4,
    rotateLeft: 4,
    rotateRight: 4,
    flipHorizontal: 4,
    flipVertical: 4,
  }
};

Note: The Viewer.js defaults are always used as standard, with the exception of the transition option.

Events

All events exposed by Viewer.js are made available by the directive as output bindings:

<img src="https://picsum.photos/2000/1500" ngxViewer2 (viewerReady)="onViewerReady($event)">

The available events are:

  • viewerReady
  • viewerShow
  • viewerShown
  • viewerHide
  • viewerHidden
  • viewerView
  • viewerViewed
  • viewerZoom
  • viewerZoomed

See Viewer.js' docs for more information on each event.

Transitions

There's a known issue with the Viewer.js transitions that are normally enabled by default. They work fine in development but break (without errors) whenever building with optimizations active (i.e building for production). To get around this, the directive disables transitions by default. If you want to re-enable them (if, for some reason, you aren't running optimizations as part of your production builds) you can set transition: true in your viewerOptions.

See this issue.

License

The MIT License

Copyright (c) 2018, WINTER AGENCY

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.