eclipsesource / tabris-js

Create native mobile apps in JavaScript or TypeScript.
https://tabrisjs.com
BSD 3-Clause "New" or "Revised" License
1.4k stars 170 forks source link

ScrollView: cannot scroll to the top with disabled animation #2116

Open cpetrov opened 4 years ago

cpetrov commented 4 years ago

Problem description

When calling scrollToY(0, {animate: false}), the content does not scroll to the top. Other y values than 0 work as expected. When animation is enabled, scrolling works as expected too. Works as expected in 3.x nightly.

Expected behavior

scrollToY(0, {animate: false}) should scroll to the top.

Environment

Code snippet

const {ui, ScrollView, TextView, Button} = require('tabris');

ui.contentView.append(
  new ScrollView({left: 0, top: 0, right: 0, bottom: 0}).append(
    new TextView({markupEnabled: true, left: 0, top: 'prev() 50', right: 0, text: [...Array(1000).keys()].map(i => `${i}<br/>`).join()}),
  ),
  new Button({centerX: 0, centerY: 0, text: 'scroll to 0 {animate: false}'}).on('tap', () => {
    ui.contentView.find(ScrollView).first().scrollToY(0, {animate: false})
  }),
  new Button({centerX: 0, centerY: 50, text: 'scroll to 1 {animate: false}'}).on('tap', () => {
    ui.contentView.find(ScrollView).first().scrollToY(1, {animate: false})
  }),
  new Button({centerX: 0, centerY: 100, text: 'scroll to 0 {animate: true}'}).on('tap', () => {
    ui.contentView.find(ScrollView).first().scrollToY(0, {animate: true})
  }),
);
mpost commented 4 years ago

Since the 2.x stream has reached EOL, it is unlikely that we are going to change its behavior. Please migrate to 3.x.