Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24963] Android: Add scrollToTop() to ScrollView

GitHub Issuen/a
TypeNew Feature
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-11-16T00:48:31.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.0.0
ComponentsAndroid
Labelsn/a
ReporterMichael Gangolf
AssigneeHans Knöchel
Created2017-07-14T18:15:47.000+0000
Updated2017-11-16T01:54:17.000+0000

Description

Currently ScrollView has a scrollToBottom() method but no scrollToTop(). While this can be achieved with scrollTo(0,0) the new scrollToTop() uses FOCUS_UP to scroll to the top position in order to solve nested problems (see: https://stackoverflow.com/a/44046801/5193915) Example:
var win = Ti.UI.createWindow({backgroundColor: '#fff'});
var view1 = Ti.UI.createView({width:20,height:20,backgroundColor:"#f00",top:0});
var view2 = Ti.UI.createView({width:20,height:20,backgroundColor:"#f0f",top:800});
var scrollView = Ti.UI.createScrollView({height:Ti.UI.FILL,width:Ti.UI.FILL});
var btn1 = Ti.UI.createButton({title:"scrollUp",top: 10,left:0});
var btn2 = Ti.UI.createButton({title:"scrollDown",bottom:10,left:0});

btn1.addEventListener("click",function(e){scrollView.scrollToTop()});
btn2.addEventListener("click",function(e){scrollView.scrollToBottom()});

win.add(scrollView);
win.add(btn1);
win.add(btn2);
scrollView.add(view1);
scrollView.add(view2);
win.open();

Comments

  1. Michael Gangolf 2017-07-14

    PR: https://github.com/appcelerator/titanium_mobile/pull/9221
  2. Hans Knöchel 2017-07-16

    [~michael] We should think about parity here as well. I made a PR to your [PR-branch](https://github.com/m1ga/titanium_mobile/pull/2) to do so, if possible, we should think about Windows as well (cc [~kiguchi]).
  3. Kota Iguchi 2017-07-16

    Created TIMOB-24964 to track this for Windows.
  4. Michael Gangolf 2017-07-16

    iOS part is merged. Thank you
  5. Joshua Quick 2017-11-15

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/9601
  6. Abir Mukherjee 2017-11-15

    FR passed; waiting for CR before merging.
  7. Abir Mukherjee 2017-11-16

    PR Merged.
  8. Lokesh Choudhary 2017-11-16

    Verified the fix in SDK 7.0.0.v20171115153702. Closing.

JSON Source