Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15352] iOS: Pull to Refresh view not displaying correctly when swiping up before releasing

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-11-14T19:32:38.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 21, 2013 Sprint 21 API
ComponentsiOS
Labelsn/a
ReporterDavide Cassenti
AssigneeVishal Duggal
Created2013-09-26T15:35:02.000+0000
Updated2017-03-21T21:46:05.000+0000

Description

Description of the issue

Having a table with search bar and pull-to-refresh view; when pulling the table down and swiping a bit up before releasing, the headerPullView and search bar are half hidden.

Steps to reproduce

1) Use the code below 2) Pull the table down 3) Before releasing, swipe a bit up Attached a couple of screenshots of the result of these actions.
Titanium.UI.setBackgroundColor('#000');
Ti.UI.iPhone.statusBarStyle = Ti.UI.iPhone.StatusBar.LIGHT_CONTENT;

var tabGroup = Titanium.UI.createTabGroup();

var win1 = Titanium.UI.createWindow({
    title : 'Table with Search',
    backgroundColor : '#fff',
    barColor: 'black',
    statusBarStyle: Ti.UI.iPhone.StatusBar.LIGHT_CONTENT
});
var tab1 = Titanium.UI.createTab({
    icon : 'KS_nav_views.png',
    title : 'Table w/ Search',
    window : win1
});

var allNoteTypes = [];
for (var i=1; i<=30; i++) {
	allNoteTypes.push({
		title : 'Plan ' + i
	});
}

var refreshView = Ti.UI.createView({
    width : "100%",
    top : 0,
    height : 22,
    backgroundColor : "#000"
});

var lblRefreshTime = Ti.UI.createLabel({
    left : 5,
    width : '55%',
    text : "refreshed 1 min ago"
});

var searchBar = Ti.UI.createSearchBar({
    barColor : "#283D5A",
    autocorrect : false,
    autocapitalization : Titanium.UI.TEXT_AUTOCAPITALIZATION_NONE,
    hintText : "SR Number",
    keyboardType : Ti.UI.KEYBOARD_NUMBERS_PUNCTUATION
});

var table = Ti.UI.createTableView({
    top : 0,
    width : "100%",
    backgroundColor : 'transparent',
    hideSearchOnSelection : false,
    data : allNoteTypes,
    search : searchBar
});

refreshView.add(lblRefreshTime);
win1.add(refreshView);
win1.add(table);

var border = Ti.UI.createView({
    backgroundColor : "#576c89",
    height : 2,
    bottom : 0
});

var tableHeader = Ti.UI.createView({
    backgroundColor : "#bcbdc1",
    width : Ti.Platform.displayCaps.platformWidth,
    height : 60
});

tableHeader.add(border);

var statusLabel = Ti.UI.createLabel({
    text : "Pull to Reload",
    left : 55,
    bottom : 30,
    height : "auto",
    color : "#FFF",
    textAlign : "center"
});

tableHeader.add(statusLabel);
table.headerPullView = tableHeader;

var pulling = false;
var reloading = false;

var overlay = Ti.UI.createView({
    opacity:.2,
    backgroundColor:'black'
});

var timeOutCounter;

function beginReloading() {
    searchBar.add(overlay);
    table.scrollable = false;
    timeOutCounter = setTimeout(function(){
        Ti.API.info('TIMEOUT');
        endReloading();
    }, 2000);
    Ti.API.info('setTimeout returned '+timeOutCounter);
}

function endReloading() {
    Ti.API.info('END Reloading called. Current Counter '+timeOutCounter);
    clearTimeout(timeOutCounter);
    searchBar.remove(overlay);
    table.scrollable = true;
    table.setContentInsets({
        top : 0
    }, {
        animated : true
    });
    reloading = false;
    statusLabel.text = "Pull down to refresh...";
}

var offset = 0;
table.addEventListener('scroll', function(e) {
    if (reloading) {
        return;
    }
    offset = e.contentOffset.y;
    if (offset <= -65.0 && !pulling) {
        pulling = true;
        statusLabel.text = "Release to refresh...";
    } else if (pulling && offset > -65.0 && offset < 0) {
        pulling = false;
        statusLabel.text = "Pull down to refresh...";
    }
});

table.addEventListener('dragEnd', function(e) {
    if (reloading) {
        return;
    }
    if (pulling && !reloading && offset <= -65.0) {
        reloading = true;
        pulling = false;
        statusLabel.text = "Reloading...";
        table.setContentInsets({
            top : 60
        }, {
            animated : true
        });
        beginReloading();
    }
});

function handleSearchBarFocus(_event){
    Ti.API.info('FOCUS');
    endReloading();
    setTimeout(function(){
        searchBar.focus();
    },300);
}

function hideNavBar() {
    win1.hideNavBar();
    table.top = 22;
}

function showNavBar() {
    win1.showNavBar();
    table.top = 0;
}

overlay.addEventListener("click", handleSearchBarFocus);

searchBar.addEventListener("focus", hideNavBar);
searchBar.addEventListener("blur", showNavBar);

tabGroup.addTab(tab1);
tabGroup.open();

Attachments

FileDateSize
iOS Simulator Screen shot 30 Sep 2013 19.24.35.png2013-09-30T17:25:20.000+000044164
iOS Simulator Screen shot 30 Sep 2013 19.24.36.png2013-09-30T17:25:20.000+000045684
ScreenShot1.PNG2013-10-23T09:41:14.000+000040080
ScreenShot2.PNG2013-10-23T09:41:14.000+000041334

Comments

  1. Vishal Duggal 2013-10-07

    Well if you are swiping up then you should cancel reload. Modify the scroll listener as shown below
       table.addEventListener('scroll', function(e) {
           offset = e.contentOffset.y;
           if (reloading) {
               if (offset > -60) 
               {
                   endReloading();
               };
               return;
           }
           if (offset <= -65.0 && !pulling) {
               pulling = true;
               statusLabel.text = "Release to refresh...";
           } else if (pulling && offset > -65.0 && offset < 0) {
               pulling = false;
               statusLabel.text = "Pull down to refresh...";
           }
       });
       
  2. Dhirendra Jha 2013-10-23

    This issue is still reproducible in below environment. Please see the attached screen shots. Hence reopening this issue. Appc Studio - 3.2.0.201310181700 SDK - 3.2.0.v20131022171645 acs -1.0.7 alloy - 1.2.2 titanium - 3.2.0 titanium-code-processor - 1.0.3 Xcode - 5.0.1 OS - Mac OS X Mavericks (10.9) Device - iPodTouch1 (v7.0.2)
  3. Vishal Duggal 2013-11-14

    The blackbar is their own js UI issue. Not ours. The workaround provided works
  4. Lee Morris 2017-03-21

    Closing ticket as the issue cannot be reproduced and due to the above comments.

JSON Source