{ "id": "167630", "key": "AC-4965", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2017-05-16T16:06:00.000+0000", "created": "2017-05-15T19:44:17.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2017-05-16T16:06:00.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "I have a scrollableView with 3 views.\r\nIf I scroll to left or right I want to load a new view in the scrollableView.\r\nThe problem is that after loading the views in the scrollableView and setting the currentView, the view disappears. This is somehow related to TIMOB-20199 but that example works. If I don't include this code: $.receiptContainer.setCurrentPage(1); everything works.\r\n\r\nThe main problem I try to resolve is that I have a lot of transactions and the app crashes if I load them all on a scrollableView, so I made a scrollable with only 3 views and try to change views while the user scrolls. I'm aware of the flickering but that's acceptable. \r\nI've attached the app directory.\r\n\r\nActual behavior: When scrolling the view disappears after loading new views and setCurrentPage to 1.\r\nExpected behavior: View should be visible and currentPage should be 1 after setCurrentPage to 1.\r\n\r\n\r\n*Index.js*\r\n\r\nfunction doClick(e) {\r\n\talert($.label.text);\r\n}\r\n\r\n$.win.open();\r\n\r\nvar all_views = [];\r\nvar views = [];\r\n\r\nfor (var i=0;i<10;i++){\r\n\tvar v = Alloy.createController('singleview', {title: i}).getView(); //A view with a label that shows i\r\n\tall_views.push(v); //Add new view\t\r\n}\r\nvar len = all_views.length;\r\nvar minIndex = 5;\r\nmaxIndex = 7;\r\n\r\n\r\nfor (var i=minIndex;i<=maxIndex;i++){\r\n\tvar v = all_views[i];\r\n\tviews.push(v);\r\n\t$.receiptContainer.addView(v);\t\t\r\n}\t\r\n\r\nvar currentIndex = 1;\r\n\r\n$.receiptContainer.addEventListener('scrollend',function(e){\r\n\tif (e.currentPage == 2){\r\n\t\tif (maxIndex+1<=len-1){\r\n\t\t\tmaxIndex++;\r\n\t\t\tvar v = all_views[maxIndex];;\r\n\t\t\tviews.push(v); //Add new view\r\n\t\t\tif (views.length>3){\r\n\t\t\t\tviews.shift(); //remove first view\r\n\t\t\t\tminIndex++;\r\n\t\t\t}\t\t\t\t\r\n\t\t\t$.receiptContainer.setViews(views);\r\n\t\t\t$.receiptContainer.setCurrentPage(1);\r\n\t\t}\r\n\t} else if (e.currentPage ==0){\r\n\t\tif (minIndex-1>=0){\r\n\t\t\tminIndex--;\r\n\t\t\tvar v = all_views[minIndex];;\r\n\t\t\tviews.unshift(v); //Add new view at beginning\r\n\t\r\n\t\t\tif (views.length>3){\r\n\t\t\t\tviews.pop(); //remove last view\r\n\t\t\t\tmaxIndex--;\r\n\t\t\t}\t\r\n\t\t\t$.receiptContainer.setViews(views);\r\n\t\t\t$.receiptContainer.setCurrentPage(1);\r\n\t\t}\r\n\t}\r\n\t\r\n});\r\n\r\n\r\n//Another way to test it, comment the scroll event and use a button instead, will make same effect\r\nvar button = Titanium.UI.createButton({title: 'click to load new views',bottom: 10,width: 100,height: 50});\r\n\r\n$.win.add(button);\r\n\r\nbutton.addEventListener('click',function(e)\r\n{\r\n $.receiptContainer.views = [all_views[1],all_views[2],all_views[3]];\r\n\t$.receiptContainer.setCurrentPage(1);\r\n});\r\n\r\n\r\n\r\n", "attachment": [ { "id": "62238", "filename": "app.zip", "author": { "name": "inzori", "key": "inzori", "displayName": "Fabian Martinez", "active": true, "timeZone": "America/Montevideo" }, "created": "2017-05-15T19:42:05.000+0000", "size": 7119507, "mimeType": "application/zip" } ], "flagged": false, "summary": "View dissapaears after loading views in scrollableView and setting currentPage", "creator": { "name": "inzori", "key": "inzori", "displayName": "Fabian Martinez", "active": true, "timeZone": "America/Montevideo" }, "subtasks": [], "reporter": { "name": "inzori", "key": "inzori", "displayName": "Fabian Martinez", "active": true, "timeZone": "America/Montevideo" }, "environment": null, "comment": { "comments": [ { "id": "419777", "author": { "name": "inzori", "key": "inzori", "displayName": "Fabian Martinez", "active": true, "timeZone": "America/Montevideo" }, "body": "Sorry, I was able to fix this problem by adding \r\n$.receiptContainer.scrollToView(1); after $.receiptContainer.setCurrentPage(1);\r\n\r\n", "updateAuthor": { "name": "inzori", "key": "inzori", "displayName": "Fabian Martinez", "active": true, "timeZone": "America/Montevideo" }, "created": "2017-05-16T13:38:47.000+0000", "updated": "2017-05-16T13:38:47.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }