Skip to content

moeproblems/ng2-zoomable

Repository files navigation

ng2-zoomable

A minimal Angular 2 image zoom directive.

Installation

To install this library, run:

$ npm install ng2-zoomable --save

Demo

Online demo is available on repo's GitHub Pages. There will be a more sophisticated demo page sometime in future :)

To run a local demo, first clone/download this repo and then inside local directory:

$ npm install
$ npm run demo

After installation is over, load https://localhost:8080/ in your browser.

Examples

First, import the ZoomableDirective directive:

import { ZoomableDirective } from 'ng2-zoomable';

Then, add ZoomableDirective to your modules declarations array:

@NgModule({
    declarations : [AppComponent, ZoomableDirective, ...],
})

Then just add the [zoomable] tag to your img element:

<img [zoomable]='zoomOptions' [src]='imageSource'>

If you want to specify source of larger image to be used for zoomed view then add [zoomableSrc] tag to your img element:

<img [zoomable]='zoomOptions' [zoomableSrc]='largeImageSource' [src]='imageSource'>

Zoom Options

zoomOptions is an optional object in this format:

peepView: {
  borderColor: '#fff',
  borderWidth: '2px',
  borderStyle: 'solid',
  cursor: 'zoom-in',
},
settings: {
  zoom: 4   // 4x zoom
}

You may choose to include/exclude any of these properties to style the boxes.

License

MIT © Moe Hosseini

About

Simple Angular2 Image Zoom (ng2-zoomable)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published