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

cordova-plugin-zoomimageview

v1.2.5

Published

An Cordova plugin for iOS and Android that allows to display an image in fullscreen and zoom in and out.

Downloads

8

Readme

README

Cordova plugin for iOS and Android that allows to display an image in fullscreen and zoom in and out.

These plugins adds a function to open a new screen to display an image. The image can be zoomed in and out. It works in landscape and portaite orientation. If the image already is on the previous screen, you can optionaly add the frame informations to get an smooth between the screens.

Supported platforms

  • Android 7+
  • iOS 13+
  • Cordova iOS 6+
  • Cordova Android 10+

Install

To install the cordova plugin perform: 'cordova plugin add cordova-plugin-zoomimageview'

Immplementation

For android you need to make sure that koltin is acitvated in your cordova config.xml. To these add the following:

    <preference name="GradlePluginKotlinEnabled" value="true" />
    <preference name="GradlePluginKotlinCodeStyle" value="official" />
    <preference name="GradlePluginKotlinVersion" value="1.6.0-RC" />

The plugin consists of only one function. Next you see a declaration of the plugins api for typescript.

    declare var window: {
        plugins: {
            zoomimageview: {
                presentImage: (
                    info: string | undefined,
                    // With the callback the plugin will inform you when the screen starts closing the screen and when the screen did close.
                    callback: (result: string) => void,
                    errorCallback: (error: any) => void
                ) => void
            }
        }
    };

The plugin expects info to be a json string which contains an ImageInfo object. The definition of the object should look like this:

export interface ImageInfo {
    
    // base64 string of the image that should be displayed. Note that only .png or .jpeg files are supported.
    image: string;
        
    // Defines if a close button should be displayed on the plugins screen. 
    closeButton: boolean;
    
    // only needed if you want a transition between the image of the current screen and the plugins screen. 
    imageRect: Rect | undefined;
}

export interface Rect {
    x: number;
    y: number;
    width: number;
    height: number;
}

The whole implemtation than could look like this:


    public show(image: string) {
    
        const rect: Rect = {
            x: this.imageControlElement.nativeElement.offsetLeft,
            y: this.imageControlElement.nativeElement.offsetTop,
            width: this.imageControlElement.nativeElement.width,
            height: this.imageControlElement.nativeElement.height
        };
        
        const info: ImageInfo = {
            image: image,
            closeButton: true,
            imageRect: rect
        };
        
        window.plugins.zoomimageview.presentImage(JSON.stringify(info), (result) => {
            console.log(result);
        }, (error) => {
            console.log(error);
        });
    }