Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): correct ScrollView.contentOffset units #12615

Merged
merged 4 commits into from May 27, 2021

Conversation

garymathews
Copy link
Contributor

@garymathews garymathews commented Mar 17, 2021

  • Correctly handle ScrollView.contentOffset units
TEST CASE
  • Scroll part way into green and click red, this should scroll back to the top
  • Scroll part way into blue and click green, this should scroll to green
  • Clicking blue should scroll 100dp into red
const win = Ti.UI.createWindow();
const scrollView = Ti.UI.createScrollView({
    layout: 'vertical',
    backgroundColor: 'white',
    width: Ti.UI.FILL,
    height: Ti.UI.FILL
});
const view_a = Ti.UI.createView({
    backgroundColor: 'red',
    width: '100%',
    height: '100%'
});
const view_b = Ti.UI.createView({
    backgroundColor: 'green',
    width: '100%',
    height: '100%'
});
const view_c = Ti.UI.createView({
    backgroundColor: 'blue',
    width: '100%',
    height: '100%'
});

view_a.addEventListener('click', e => {
    console.log(`previous contentOffset: ${JSON.stringify(scrollView.contentOffset)}`);
    scrollView.contentOffset = {
        x: 0,
        y: 0
    };
    console.log(`new contentOffset: ${JSON.stringify(scrollView.contentOffset)}`);
});

view_b.addEventListener('click', e => {
    console.log(`previous contentOffset: ${JSON.stringify(scrollView.contentOffset)}`);
    scrollView.contentOffset = {
        x: 0,
        y: view_a.rect.height
    };
    console.log(`new contentOffset: ${JSON.stringify(scrollView.contentOffset)}`);
});

view_c.addEventListener('click', e => {
    console.log(`previous contentOffset: ${JSON.stringify(scrollView.contentOffset)}`);
    scrollView.contentOffset = {
        x: 0,
        y: '100dp'
    };
    console.log(`new contentOffset: ${JSON.stringify(scrollView.contentOffset)}`);
});

scrollView.add([
    view_a,
    view_b,
    view_c
]);

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

JIRA Ticket
#12608

@garymathews garymathews added this to the 10.1.0 milestone Mar 17, 2021
@build build requested a review from a team March 17, 2021 23:55
@build
Copy link
Contributor

build commented Mar 17, 2021

Fails
🚫 Tests have failed, see below for more information.
Messages
📖 ✊ The commits in this PR match our conventions! Feel free to Rebase and Merge this PR when ready.
📖 ❌ 9 tests have failed There are 9 tests failing and 957 skipped out of 15323 total tests.

Tests:

ClassnameNameTimeError
android.emulator.Titanium.UI.NavigationWindowbasic open/close navigation (5.0.2)10.011
Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (app.js)
android.emulator.Titanium.UI.Windowwindow_navigation (5.0.2)30.007
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (app.js)
android.emulator.Titanium.UI.ScrollViewcontentOffset (5.0.2)1.08
Error: Uncaught Uncaught AssertionError
android.emulator.Titanium.UI.View"after all" hook for "rgba fallback" (5.0.2)23.086
Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (app.js)
android.emulator.Titanium.UI.View"after each" hook for "getOrCreateView() should always return a View" (5.0.2)12.984
Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (app.js)
ios.ipad.Titanium.UI.ScrollViewcontentOffset (14.4.0)0.117
Error: Uncaught expected 2 to equal 10
ios.iphone.Titanium.UI.ScrollViewcontentOffset (14.4.0)0.114
Error: Uncaught expected 2 to equal 10
ios.macos.Titanium.Filesystem.File#getDirectoryListing() can access resource directory files (10.15.7)2.263
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (app.js)
run@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-12615/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/ti.main.js:9154:22
processImmediateQueue@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-12615/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/ti.main.js:9217:18
drainQueues@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-12615/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/ti.main.js:9194:52
ios.macos.Titanium.UI.ScrollViewcontentOffset (10.15.7)0.199
Error: Uncaught expected 5 to equal 10

Generated by 🚫 dangerJS against 5fd2246

@garymathews garymathews force-pushed the TIMOB-28397 branch 2 times, most recently from ac87216 to 9e4ad84 Compare March 18, 2021 00:20
@garymathews garymathews linked an issue Mar 18, 2021 that may be closed by this pull request
Copy link
Contributor

@jquick-axway jquick-axway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: Pass

@garymathews garymathews added the backport 10_2_X when applied, PRs with this label will get an auto-generated backport to 10_2_X branch on merge label Mar 18, 2021
@@ -713,7 +734,7 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP

if (key.equals(TiC.PROPERTY_CONTENT_OFFSET)) {
setContentOffset(newValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there is no need to call it here. We will call setContentOffset(int x, int y) later from onScrollChanged which is triggered by the scrollTo on the next line.

@lokeshchdhry
Copy link
Contributor

FR Passed.

@sgtcoolguy sgtcoolguy merged commit 61fda92 into tidev:master May 27, 2021
@build build removed the backport 10_2_X when applied, PRs with this label will get an auto-generated backport to 10_2_X branch on merge label May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android. ScrollView. Inconsistent units in contentOffset
6 participants