Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-119] API - Horizontal Scrollable Views

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:52:03.000+0000
Affected Version/sn/a
Fix Version/sRelease 0.7.0
ComponentsiOS
Labelsn/a
ReporterNolan Wright
AssigneeBlain Hamon
Created2011-04-15T02:23:53.000+0000
Updated2011-04-17T01:52:03.000+0000

Description

Purpose

Provide a set of Web Views that can be scrolled through left-to-right or right-to-left.

API Spec


//  create views 
// NOTE VIEWS CAN BE WebViews, TableViews, GroupedViews or Image Views (new)
var view1 = Titanium.UI.createWebView({url:'view1.html'});
var view2 = Titanium.UI.createWebView({url:'view2.html'});
var view3 = Titanium.UI.createWebView({url:'view3.html'});
var view4 = Titanium.UI.createWebView({url:'view4.html'});

// create scrollable view
// NOTE pagingControl is probably iPhone only
Titanium.UI.createScrollableView({
    views:[view1, view2, view3, view4],
    showPagingControl:true
});

// add view to window
Titanium.UI.currentWindow.addView(scrollableView);

// show view
Titanium.UI.currentWindow.showView(scrollableView);

// scroll to a particular view by index
scrollableView.scrollToView(0);

// scroll to a particular view by instance
scrollableView.scrollToView(view2);

scrollableView.addEventListener('scroll', function(e)
{
    e.view  // the object handle to the view that is about to become visible
});

Comments

  1. Blain Hamon 2011-04-15

    I was actually thinking more of:

    var view1 = Titanium.UI.createWebView({url:'view1.html'});
    var view2 = Titanium.UI.createWebView({url:'view2.html'});
    var view3 = Titanium.UI.createWebView({url:'view3.html'});
    var view4 = Titanium.UI.createWebView({url:'view4.html'});

    Titanium.UI.currentWindow.addView(view1);
    Titanium.UI.currentWindow.addView(view2);
    Titanium.UI.currentWindow.addView(view3);
    Titanium.UI.currentWindow.addView(view4);

    Titanium.UI.currentWindow.showScrollingViews([view1, view2, view3, view4]);

    The reasons being that each html page at this scale should be able to have full access to Titanium. That means each web page needs to be its own webView already.

    That would mean a scrollableView that has subviews. I'm hesitant to do this as it does change more underlying assumptions (IE, that a view's superview is no longer the window) as well as opens up some recursion issues (What happens when you have a scrollableView that contains a scrollableView, or better yet, contains itself?).

    By moving the scrollableView's abilities to be a property of the userWindow makes it easier to maintain the relationship as well as makes it much easier to handle edge cases (IE, to have the page control stay placed above and not overlap the toolbar).

    The example above is rather verbose. Would it be better functionality that implicit adds are allowed? (IE, setScrollingViews adds views when necessary?)

JSON Source