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

ionic2-zoom-area

v1.0.16

Published

A zoom area component with pinch and pan support.

Downloads

37

Readme

npm npm npm

A zoom area for Ionic 2

IMPORTANT: Versions 1.0.12 and 1.0.13 will not work as expected, please use <=1.0.11 or >=1.0.14 instead.

A zoom area component with pinch support to zoom any element in page

To see this in action, checkout the example project here.

IMPORTANT: This module requires Angular Animations and should be included in the app module.

Screenshot

Quick Example

<zoom-area>
  <div>
      zoom it
  </div>
  or
  <img src="zoom-it.jpg" alt="zoom it">
</zoom-area>

Installation

Add Angular Animations

npm i --save @angular/animations

Import BrowserAnimationsModule in your app's module(s)

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

And then

imports: [
  ...
  BrowserAnimationsModule,
  ...
]

Install the module via NPM

npm i --save ionic2-zoom-area

Import it in your app's module(s)

Import ZoomAreaModule.forRoot() in your app's main module

import { ZoomAreaModule } from 'ionic2-zoom-area';

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

If your app uses lazy loading, you need to import ZoomAreaModule in your shared module or child modules:

import { ZoomAreaModule } from 'ionic2-zoom-area';

@NgModule({
    ...
    imports: [
      ...
      ZoomAreaModule
    ],
    ...
})
export class SharedModule {}

Usage

zoom-area Component

Inputs

scale

(optional) (two-way) The scale of your initial zoom. Defaults to 1.

controls

(optional) (two-way) It allow you to hide or show zoom controls. Defaults to true.

Outputs

afterZoomIn

Listen to this event to be notified when the user interact with zoom in.

afterZoomOut

Listen to this event to be notified when the user interact with zoom out.

ZoomAreaProvider Provider

notifyScroll

notifyScroll(): void

It broadcast an event when user scroll content inside zoom area.

onScroll$

onScroll$: Observable

It allows you to listen for a scroll event inside your zoom area. You can use it to collapse you header for example.

this.zoomAreaProvider.onScroll$.subscribe(state => {
  if (state === this.zoomAreaProvider.SCROLL_STATE.COLLAPSED) {
    console.log('Hide header');
  }

  if (state === this.zoomAreaProvider.SCROLL_STATE.EXPANDED) {
    console.log('Show header');
  }
});

scrollState$

scrollState$: Observable

It allows you to listen for a change in scroll state.

this.zoomAreaProvider.scrollState$.subscribe(state => {
  console.log('Do whatever you want when scrollState change');
});

setCenter (x: number, y: number)

setCenter: Function

It allows you to change the position of the zoom manually if zoom scale is greather than 1.

this.zoomAreaProvider.setCenter(x, y);
this.zoomAreaProvider.setCenter(20, 50);

Examples

Basic example

Example with methods

<zoom-area [(scale)]="scale" (afterZoomIn)="afterZoomIn($event)" (afterZoomOut)="afterZoomOut($event)" [(controls)]="showControls">
    <div>Zoom It</div>
    or
    <img src="assets/image-to-zoom.jpg" alt="Zoom It">
</zoom-area>

Known Issues 🤬

  • ✅(Fixed in 1.0.12) Vertical pan is in conflict with scroll event and are not fired like horizontal pan.

Roadmap

  • ✅(Fixed in 1.0.10) - Add support to move center of zoom

Contribution

  • Having an issue? or looking for support? Open an issue and we will get you the help you need.
  • Got a new feature or a bug fix? Fork the repo, make your changes, and submit a pull request.

Support this project

If you find this project useful, please star the repo to let people know that it's reliable. Also, share it with friends and colleagues that might find this useful as well. Thank you :smile: