GithubHelp home page GithubHelp logo

dibyanshu / ng-image-viewerlib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vishwalaya/angular-image-viewer

0.0 0.0 0.0 2.71 MB

Image Viewer For Angular 17+ . It also has various functionality like Image FullScreent, Rotate, Zoom etc.

Home Page: https://pravinsharma.github.io/angular-image-viewer

License: MIT License

JavaScript 9.07% TypeScript 63.66% HTML 13.31% SCSS 13.96%

ng-image-viewerlib's Introduction

Angular Image Viewer

demo: https://pravinsharma.github.io/angular-image-viewer/

A configurable Angular image viewer component, compatible with Angular 15

Features:

  • Compatible with Angular 15
  • Configurable
  • Rotate image
  • Zoom image
  • Drag to move image
  • Toggle Full Screen mode

Set up

To use default configuration, simply import the ImageViewerModule into your module, like so:

import { AngularImageViewerModule } from "@clarivate/angular-image-viewer";

@NgModule({
  //...
  imports: [
    //...
    AngularImageViewerModule
  ],
  //...
})

Then, add the component to your template, providing an array of image URLs. You can also optionally add an index, to indicate which image should be shown first. The default will be the first item in the array.

<div class="container">
  <angular-image-viewer  [src]="images" [(index)]="imageIndex"></angular-image-viewer>
</div>

By default, the image viewer will fill its container. If you wish to restrict the size, simply place it within a div, and set the size constraints on the div:

.container {
  position: relative;
  height: 600px;
  width: 600px;
}

Configuration

Configuration can be provided at the module level (by passing the object as an argument to forRoot(), or at the component level, by passing it as the config input. Any configuration provided at the component level will override that which is set at the module level.

The configuration object is structured as below. All values are optional, and if omitted, the default value shown below will be used.

{
  btnClass: 'default', // The CSS class(es) that will apply to the buttons
  zoomFactor: 0.1, // The amount that the scale will be increased by
  containerBackgroundColor: '#e4dede', // The color to use for the background. This can provided in hex, or rgb(a).
  primaryColor: '', // Color to use for all buttons image.
  wheelZoom: true, // If true, the mouse wheel can be used to zoom in
  allowFullscreen: true, // If true, the fullscreen button will be shown, allowing the user to enter fullscreen mode
  allowKeyboardNavigation: true, // If true, the left / right arrow keys can be used for navigation
  btnIcons: { // The icon classes that will apply to the buttons. By default, font-awesome is used.
    zoomIn: 'fa fa-plus',
    zoomOut: 'fa fa-minus',
    rotateClockwise: 'fa fa-repeat',
    rotateCounterClockwise: 'fa fa-undo',
    next: 'fa fa-arrow-right',
    prev: 'fa fa-arrow-left',
    fullscreen: 'fa fa-arrows-alt',
  },
  btnShow: {
    zoomIn: true,
    zoomOut: true,
    rotateClockwise: true,
    rotateCounterClockwise: true,
    next: true,
    prev: true
  }
};

To add additional buttons use the following

<angular-image-viewer [src]="images" 
                  [config]="{customBtns:[{name: 'link', icon: 'fa fa-paperclip'}]}"
                  (customImageEvent)="handleEvent($event)">
</angular-image-viewer>
handleEvent(event: customImageEvent) {
    console.log(`${event.name} has been click on img ${event.imageIndex + 1}`);

    switch (event.name) {
      case 'print':
        console.log('run print logic');
        break;
    }
}

Local setup for this branch:

  • Add respective version of this component. yarn add @clarivate/angular-image-viewer.
  • yarn serve-lib is to compile your changes in projects\angular-image-viewer and it will update in dist folder. But to reflect in UI, update projects\angular-image-viewer\ng-package.json file dest to node_module location. "dest": "../../node_modules/@clarivate/angular-image-viewer",
  • yarn start to get the application up.

Note: This package is built using the idea from ngx-image-viewer(https://github.com/jpilfold/ngx-image-viewer). It has advantage that it uses latest dependencies which fixes Issue #23 & #29 i.e related to FullScreen Image.

ng-image-viewerlib's People

Contributors

deepakgonda avatar fradiablo avatar kdimatteo avatar mohanraj-86 avatar muthu-clarivate avatar pravinsharma avatar pravinsharma-in avatar venu369 avatar vishwalaya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.