GithubHelp home page GithubHelp logo

nvdnkpr / titouchgallery Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gbaldera/titouchgallery

0.0 2.0 0.0 656 KB

Titanium Mobile native Android module for touch gallery, using viewpager. Allows pinch zoom and pan for images

License: Other

titouchgallery's Introduction

TiTouchGallery Module

Description

TiTouchGallery is a native Android module, which allows you to create a gallery view, with zoom (pinch / double tap) and pan support, in your Titanium Android app.

##Copyright

This module is a fork of the android gallery widget from Dreddik with some changes.
Thanks Dreddik for share this.

##Download

Grab the lastest build from the dist folder

Accessing the TiTouchGallery Module

Simply add the following lines to your tiapp.xml file:

<modules>
    <module platform="android">com.gbaldera.titouchgallery</module> 
</modules>

To access this module from JavaScript, you would do the following:

var titouchgallery = require("com.gbaldera.titouchgallery");

The titouchgallery variable is a reference to the Module object.

Properties

####images : String[]

Array of images to display in the gallery (Only Remote images are supported for now)

####currentPage : Number

index of the active page

Methods

List of methods supported in this module:

Gallery creation

var proxy = titouchgallery.createTouchGallery({
    images: [
        "http://cs407831.userapi.com/v407831207/18f6/jBaVZFDhXRA.jpg",
        "http://cs407831.userapi.com/v4078f31207/18fe/4Tz8av5Hlvo.jpg",
        "http://cs407831.userapi.com/v407831207/1906/oxoP6URjFtA.jpg",
        "http://cs407831.userapi.com/v407831207/190e/2Sz9A774hUc.jpg",
        "http://cs407831.userapi.com/v407831207/1916/Ua52RjnKqjk.jpg",
        "http://cs407831.userapi.com/v407831207/191e/QEQE83Ok0lQ.jpg"
    ],
    currentPage:2
});

getImages : String[]

Get the array with the images displayed in the gallery.

Arguments

None

setImages

Set the array with the images to be displayed in the gallery.

Arguments
  • Images [array]: Images to be displayed in the gallery

addImage

Adds a new image to the gallery

Arguments
  • Image [string]: Image URL to be added to the gallery

removeImage

Removes the specified image from the gallery

Arguments
  • Image [string]: Image URL to be removed from the gallery

getCount : Number

Get the total number of images in the gallery.

Arguments

None

moveNext

Sets the current page to the next consecutive page in images.

Arguments

None

movePrevious

Sets the current page to the previous consecutive page in images.

Arguments

None

getCurrentPage : Number

Gets the value of the currentPage property.

Arguments

None

setCurrentPage

Sets the value of the currentPage property.

Arguments
  • currentPage [number]: New value for the currentPage property

Events

singletap

Fired when the device detects a single tap against the view.

Properties

  • currentPage : Index of the image.
  • url : URL of the image.
  • source : Source object that fired the event.
  • type : String Name of the event fired.
  • x : NumberX coordinate of the event from the source view's coordinate system.
  • y : NumberY coordinate of the event from the source view's coordinate system.

longpress

Fired when the device detects a long press against this view.

Properties

  • currentPage : Index of the image.
  • url : URL of the image.
  • source : Source object that fired the event.
  • type : String Name of the event fired.
  • x : NumberX coordinate of the event from the source view's coordinate system.
  • y : NumberY coordinate of the event from the source view's coordinate system.

scroll

Fired when the gallery changed the page

Properties

  • currentPage : Index of the image.
  • url : URL of the image.

Usage


var win = Ti.UI.createWindow({
    backgroundColor:'#000'
});

var titouchgallery = require('com.gbaldera.titouchgallery');

if (Ti.Platform.name == "android") {
    var proxy = titouchgallery.createTouchGallery({
        images: [
            "http://cs407831.userapi.com/v407831207/18f6/jBaVZFDhXRA.jpg",
            "http://cs407831.userapi.com/v4078f31207/18fe/4Tz8av5Hlvo.jpg",
            "http://cs407831.userapi.com/v407831207/1906/oxoP6URjFtA.jpg",
            "http://cs407831.userapi.com/v407831207/190e/2Sz9A774hUc.jpg",
            "http://cs407831.userapi.com/v407831207/1916/Ua52RjnKqjk.jpg",
            "http://cs407831.userapi.com/v407831207/191e/QEQE83Ok0lQ.jpg"
        ]
    });
    proxy.addEventListener("scroll", function(e){
        Ti.API.debug("Scroll event fired: " + JSON.stringify(e));
    });
    proxy.addEventListener("singletap", function(e){
        alert("Page: " + e.currentPage);
        Ti.API.debug("SingleTap event fired: " + JSON.stringify(e));
    });
    proxy.addEventListener("longpress", function(e){
        alert("Page: " + e.currentPage);
        Ti.API.debug("LongPress event fired: " + JSON.stringify(e));
    });

    win.add(proxy);
}

win.open();

TODO

  • Add support for local images.
  • Cache remote images.

Changelog

  • 1.1:
    • Fixed single tap and added long press events
  • 1.0: Initial version

Author

Gustavo Rodriguez Baldera

www.gbaldera.com

License

It's open source and it's under DBAD License

titouchgallery's People

Contributors

gbaldera avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.