by 000panther | v2.1.0
A widget to easily swipe and zoom through images. Fork with disabled orientation.
npm i --save nativescript-image-swipe-saturn

Build Status npm downloads npm downloads npm

A NativeScript widget that will allow you to easily swipe and zoom through a list of images.




Run the following command from the root of your project:

tns plugin add nativescript-image-swipe

This command automatically installs the necessary files, as well as stores nativescript-image-swipe as a dependency in your project's package.json file.


There is no additional configuration needed!



  • pageChanged
    Triggered when the user swipes to the next/previous image in the list.

Static Properties

  • pageChangedEvent - String
    String value used when hooking to pageChanged event.

Instance Properties

  • ios - UIScrollView
    Gets the native iOS view that represents the user interface for this component. Valid only when running on iOS.

  • android -
    Gets the native android widget that represents the user interface for this component. Valid only when running on Android OS.

  • items - Array | ObservableArray
    Gets or sets the items collection of the ImageSwipe. The items property can be set to an array or an object defining length and getItem(index) method.

  • pageNumber - Number
    Gets or sets the currently visible image.

  • imageUrlProperty - string
    Gets or sets the property inside the items' object that defines the Url from where to load the images

  • allowZoom - boolean (default: true)
    Gets or sets whether zoom is enabled


You need to add xmlns:is="nativescript-image-swipe" to your page tag, and then simply use <is:ImageSwipe/> in order to add the widget to your page.

<!-- test-page.xml -->
<Page xmlns="" xmlns:is="nativescript-image-swipe" navigatingTo="navigatingTo">
<is:ImageSwipe items="{{ items }}" imageUrlProperty="imageUrl"
pageNumber="{{ pageNumber }}" pageChanged="pageChanged" backgroundColor="#000000">

// test-page.ts
import { EventData, Observable } from "data/observable";
import { ObservableArray } from "data/observable-array";
import { Page } from "ui/page";

import { PageChangeEventData } from "nativescript-image-swipe";

let viewModel: Observable;

export function navigatingTo(args: EventData) {
const page = args.object as Page;
const items = new ObservableArray();

items.push({ imageUrl: "" });
items.push({ imageUrl: "" });
items.push({ imageUrl: "" });
items.push({ imageUrl: "" });
items.push({ imageUrl: "" });

viewModel = new Observable();
viewModel.set("items", items);
viewModel.set("pageNumber", 3);

page.bindingContext = viewModel;

export function pageChanged(e: PageChangeEventData) {
console.log(`Page changed to ${}.`);

Usage in Angular

In order to use the ImageSwipe you must register it in BOTH your main.ts and main.aot.ts!

// main.ts
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
import { registerElement } from "nativescript-angular/element-registry";

import { AppModule } from "./app.module";

registerElement("ImageSwipe", () => require("nativescript-image-swipe/image-swipe").ImageSwipe);

<!-- test.component.html -->
<ImageSwipe [items]="items" imageUrlProperty="imageUrl"
[pageNumber]="pageNumber" (pageChanged)="pageChanged($event)" backgroundColor="#000000">

// test.component.ts
import { Component, OnInit } from "@angular/core";
import { PageChangeEventData } from "nativescript-image-swipe";

selector: "demo",
templateUrl: "./test.component.html",
export class ImageSwipeComponent implements OnInit {
public items: any[] = [];
public pageNumber: number = 3;

ngOnInit(): void {
this.items.push({ imageUrl: "" });
this.items.push({ imageUrl: "" });
this.items.push({ imageUrl: "" });
this.items.push({ imageUrl: "" });
this.items.push({ imageUrl: "" });

public pageChanged(e: PageChangeEventData) {
console.log(`Page changed to ${}.`);

Working with Webpack+Uglify

In case you are uing webpack and also are minifying/uglifying your code, there are some specific names that should be excluded from the uglification for the widget to work properly. The ImageSwipe widget exports those and you need to add them to the mangle exclude option of the uglifyjs plugin in the webpack.common.js file:

var imageSwipeMangleExcludes = require("nativescript-image-swipe/uglify-mangle-excludes").default;
module.exports = function (platform, destinationApp) {
if (process.env.npm_config_uglify) {
plugins.push(new webpack.LoaderOptionsPlugin({
minimize: true

//Work around an Android issue by setting compress = false
var compress = platform !== "android";
plugins.push(new webpack.optimize.UglifyJsPlugin({
mangle: {
except: nsWebpack.uglifyMangleExcludes.concat(imageSwipeMangleExcludes),
compress: compress,


This repository includes both Angular and plain NativeScript demos. In order to run those execute the following in your shell:

$ git clone
$ cd nativescript-image-swipe
$ npm install
$ npm run demo-ios

This will run the plain NativeScript demo project on iOS. If you want to run it on Android simply use the -android instead of the -ios sufix.

If you want to run the Angular demo simply use the demo-ng- prefix instead of demo-.