Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Momentum scrolling feels unnatural #6

Closed
kjb opened this issue Jan 16, 2012 · 11 comments
Closed

Momentum scrolling feels unnatural #6

kjb opened this issue Jan 16, 2012 · 11 comments

Comments

@kjb
Copy link

kjb commented Jan 16, 2012

Momentum scrolling of a long list feels very different from native momentum scrolling (iOS, Android) (see http://jqmobi.com/testdrive and select "Selectors" tab.)

@imaffett
Copy link
Contributor

It's virtually impossible to get the exact native performance. Since only iOS 5 allows fixed positioning (and scrolling divs which act funky), everyone is stuck writing their own scrolling library.

If you can provide more info, we'll be happy to look into this.

@kjb
Copy link
Author

kjb commented Jan 17, 2012

The iScroll-4 library has an implementation that feels pretty good.

It uses a momentum function as follows:

_momentum: function (dist, time, maxDistUpper, maxDistLower, size) {
    var deceleration = 0.0006,
        speed = m.abs(dist) / time,
        newDist = (speed * speed) / (2 * deceleration),
        newTime = 0, outsideDist = 0;

    // Proportinally reduce speed if we are outside of the boundaries 
    if (dist > 0 && newDist > maxDistUpper) {
        outsideDist = size / (6 / (newDist / speed * deceleration));
        maxDistUpper = maxDistUpper + outsideDist;
        speed = speed * maxDistUpper / newDist;
        newDist = maxDistUpper;
    } else if (dist < 0 && newDist > maxDistLower) {
        outsideDist = size / (6 / (newDist / speed * deceleration));
        maxDistLower = maxDistLower + outsideDist;
        speed = speed * maxDistLower / newDist;
        newDist = maxDistLower;
    }

    newDist = newDist * (dist < 0 ? -1 : 1);
    newTime = speed / deceleration;

    return { dist: newDist, time: mround(newTime) };
},

Under an MIT-type license: https://github.com/cubiq/iscroll/blob/master/license.txt

@ryanflorence
Copy link

Sencha Touch's implementation feels better on Android than native. It can be done.

@matthias
Copy link

The same occurs for the carousel. Lists and carousel seem to have a maximum speed that is well bellow the speed of my thumb / fingers.

@sindresorhus
Copy link

Scrollability is also pretty smooth.

@imaffett
Copy link
Contributor

Sencha Touch's performance has been sub par on every device we have tested (Galaxy S, Droid, Droid Bionic, Droid X/X2).

I think the issue is the easing method. @kjb please commit a patch/pull request and we'll test it.

@imaffett
Copy link
Contributor

I broke out an iPad and found the big culprit is the CSS on the list item elements. When I remove them, scrolling is much better. We're redoing the CSS on the kitchen sink demo for the list items. Also looking into the momentum from iscroll4

imaffett pushed a commit that referenced this issue Jan 17, 2012
#6 - changed css to reduced images and gradients.  Added new momentum code modified from iscroll
#10 - Fixed select boxes on Android 2.3.5 and added "Close" button
#13 - Changed opera to look for "Opera Mobi"
#9 - Added new 0.9.1 release which should work fine.
@cjvraay
Copy link

cjvraay commented Jan 31, 2012

It would also help if the "stretch tension" increased as you scroll beyond the bounds of the content, so as you drag the amount of movement becomes less.

@imaffett
Copy link
Contributor

A lot of people seem to have opinions on how things should work, but very few are submitting patches. We're limited in time and resources for what we want to get in the 1.0 release. For the most part, we are happy with how core pieces function, so when we see requests like this it's really low on the priority list.

@imaffett
Copy link
Contributor

@cjvraay - Ok...turns out we had something like this in another project, so it's been merged in and will be apart of the next update.

@cjvraay
Copy link

cjvraay commented Feb 2, 2012

Thanks @imaffett

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants