{ "id": "64066", "key": "TIMOB-3434", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2017-05-02T21:47:28.000+0000", "created": "2011-04-15T03:45:09.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "default", "defaultscrollposition", "position", "scroll", "scrollview", "tbs-1.9.0" ], "versions": [], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-05-02T21:47:28.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": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}

Howdy!

\n

After/during creating a scrollView, I would like to be able to\nset the default starting position of the content viewed.

\n

e.g.

\n


\nvar scrollView = Ti.UI.createScrollView({

\n{mkd-extraction-47bdccb44f8a2210a9ce265263aa5916}\n

});

\n

or

\n


\nvar scrollView = Ti.UI.createScrollView({

\n{mkd-extraction-03d353c087c05a7679e3039f2021f6fc}\n

}); scrollView.scrollTo(250, 0); <-- works but straight after\nthis event is fired, another scroll event sets the position to 0,0.\nI think the \"resetting/default scroll event\" occurs when the window\nis opened.
\n// add more content to scrollView

\n

win.add(scrollView);
\nwin.open();

\n

I think the property \"defaultScrollPosition: [250, 0]\" would be\ngreat.

\n

Tested on the KitchenSink example - scroll_views_tabs.js

\n

Thanks in advance!

\n

TM

{html}", "attachment": [], "flagged": false, "summary": "ScrollView: Not able to set default scroll position of content to be viewed.", "creator": { "name": "tigermunky", "key": "tigermunky", "displayName": "TigerMunky", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "tigermunky", "key": "tigermunky", "displayName": "TigerMunky", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "166896", "author": { "name": "framirez", "key": "framirez", "displayName": "Francisco Antonio Duran Ramirez", "active": true, "timeZone": "America/Los_Angeles" }, "body": "h3. Problem\r\n\r\nA scrollView created by Ti.UI.createScrollView always seems to start at position (0, 0) regardless of what you set contentOffset to. If you set scrollView.contentOffset after the view is already on the screen, then it does have an effect (of casual scrolling...).\r\n \r\nh3. Reproducible steps:\r\n \r\n1.Run the code below.\r\n \r\nh3. Expected behavior\r\n\r\nCustomer wants to scroll to a specific point.\r\n\r\nh3. Sample Code:\r\n\r\n{code}\r\nvar win = Titanium.UI.createWindow({ \r\n layout:'vertical',\r\n backgroundColor:'#fff'\r\n});\r\n\r\nvar scrollView = Ti.UI.createScrollView({\r\n\tshowHorizontalScrollIndicator:true, showVerticalScrollIndicator:true,\r\n\twidth: 250, height: 250, top: 50,\r\n\tborderColor:'green', borderWidth:1,\r\n\tcontentWidth:1000, contentHeight:1000,\r\n\tcontentOffset: { x:600, y:600}\r\n});\r\n\r\nfor(var i=0; i<10; i++) {\r\n\tfor(var j=0; j<10; j++) {\r\n\t\tscrollView.add(Ti.UI.createLabel({\r\n\t\t\ttop:i*100, left:j*100,\r\n\t\t\twidth:100, height:100,\r\n\t\t\ttext:i+':'+j, textAlign:'center',\r\n\t\t\tcolor:'white',\r\n\t\t\tbackgroundColor:'#A0' + Number(i%2*8).toString(16) +'0'+ Number(8-j%2*8).toString(16)+'0',\r\n\t\t\tborderColor:'black', borderWidth:1 \r\n\t\t}));\r\n\t}\r\n}\r\n\r\nvar button = Ti.UI.createButton({title:'Center', width:100, height:50});\r\nbutton.addEventListener('click', function() {\r\n\tscrollView.contentOffset = { x:450, y:450};\r\n});\r\n\r\nscrollView.addEventListener('scroll', function() {\r\n\tTi.API.info('Offset: (' + scrollView.contentOffset.x + ', ' + scrollView.contentOffset.y + ')');\r\n});\r\nwin.add(scrollView);\r\nwin.add(button);\r\nwin.open();\r\n\r\n{code}\r\n\r\n\r\n", "updateAuthor": { "name": "framirez", "key": "framirez", "displayName": "Francisco Antonio Duran Ramirez", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-09-25T19:55:08.000+0000", "updated": "2011-10-10T21:09:03.000+0000" }, { "id": "166933", "author": { "name": "zpapp", "key": "zpapp", "displayName": "Zsombor Papp", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "zpapp", "key": "zpapp", "displayName": "Zsombor Papp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-09-26T07:23:16.000+0000", "updated": "2011-10-09T19:26:42.000+0000" }, { "id": "329891", "author": { "name": "bearus", "key": "bearus", "displayName": "Be Rushton", "active": true, "timeZone": "Australia/Brisbane" }, "body": "Quite surprised this bug is still open... seems like a common thing to be able to do...\r\nThere is currently no way to set the content offset on creation. The only way is to set the property after the view has been laid out :(\r\n", "updateAuthor": { "name": "bearus", "key": "bearus", "displayName": "Be Rushton", "active": true, "timeZone": "Australia/Brisbane" }, "created": "2014-10-29T06:13:29.000+0000", "updated": "2014-10-29T06:13:29.000+0000" }, { "id": "418873", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Resolving ticket as Invalid as there is now a new version of Kitchen Sink available and we no longer support the version which relates to this ticket.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-05-02T21:47:28.000+0000", "updated": "2017-05-02T21:47:28.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }