Skip to content

carlos-dubon/ng-zoom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

45 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ng-zoom ๐Ÿ”๏ธ

Image zoom directive for Angular based apps.

ng-zoom-demo.mp4

Stars Forks Issues NPM downloads License

โœจ Features

  • ๐Ÿ‘Œ Zero-dependency
  • ๐Ÿงฌ Perfect for dynamic content, mutation-agnostic โ€” you can do whatever you want with images, it'll work
  • โšก๏ธ Blazing fast โ€” no matter if it's 10 images or 10,000
  • ๐Ÿค“ Powered by quirky math to precisely calculate everything and do the trick with only one transformation
  • ๐Ÿฆ Zero-configuration by default but extensible when you need it
  • ๐Ÿ—ฟ Works flawlessly even on iOS Safari, in every orientation, with every image no matter the size and dimensions

๐Ÿ”‘ License

MIT

๐Ÿ–ฅ Environment Support

  • Angular ^13.0.0

๐Ÿ“ฆ Installation

$ npm install ng-zoom

๐Ÿ”จ Usage

Import the ng-zoom module into the app.module.ts file.

import { NgZoomModule } from 'ng-zoom';

@NgModule({
  imports: [NgZoomModule],
})
export class AppModule {}

Use the ng-zoom directive in your .html files.

<img ng-zoom src="lake.png" alt="lake" />

โš™๏ธ Configuration

Pass a NgZoomConfig object to the module's forRoot method.

import { NgZoomConfig, NgZoomModule } from 'ng-zoom';

const config: NgZoomConfig = {
  backgroundColor: 'skyblue',
};

@NgModule({
  imports: [NgZoomModule.forRoot(config)],
})
export class AppModule {}

๐Ÿท๏ธ Config reference

Property Type Default Description
backgroundColor string #ffffff The background color of the wrapper element.
scaleUp boolean true Defines if an element should be scaled up when zooming or maintain its original size.
padding number 20 Padding in pixels
duration number 300 The duration of the zoom animation in milliseconds.