feathersui / feathersui-starling

User interface components for Starling Framework and Adobe AIR
https://feathersui.com/learn/as3-starling/
Other
915 stars 386 forks source link

Animation Stop problem on Spinner list + horizontal spinner layout #1771

Closed raresn closed 5 years ago

raresn commented 5 years ago

Hello, We found the following bug: When creating Spinner list with the elements displayed horizontally, if you move it a little bit it snaps to pages -> which is the wanted result. BUT - if you throw the list left or right and click, it will stop in between the pages, disregarding the page snapping.

Here is the code to replicate:

var list:SpinnerList = new SpinnerList();

list.dataProvider = new ArrayCollection(
[
{ text: "Milk" },
{ text: "Eggs" },
{ text: "Bread" },
{ text: "Chicken" },
{ text: "Milk1" },
{ text: "Eggs1" },
{ text: "Bread1" },
{ text: "Chicken1" },
{ text: "Milk2" },
{ text: "Eggs2" },
{ text: "Bread2" },
{ text: "Chicken2" },
{ text: "Milk3" },
{ text: "Eggs3" },
{ text: "Bread3" },
{ text: "Chicken3" },
]);
list.width = 320;
list.height = 120;
list.y = 400;

list.itemRendererFactory = function():IListItemRenderer
{
var renderer:DefaultListItemRenderer = new DefaultListItemRenderer();
renderer.labelField = "text";
renderer.width = 200;
renderer.height = 40;
return renderer;
};

spinnerLayout = new HorizontalSpinnerLayout();
spinnerLayout.horizontalAlign = HorizontalAlign.LEFT;
spinnerLayout.repeatItems = true;
spinnerLayout.requestedColumnCount = 3;
spinnerLayout.typicalItemWidth = 100;
spinnerLayout.typicalItemHeight = 100;
spinnerLayout.resetTypicalItemDimensionsOnMeasure = true;
spinnerLayout.padding = 0;
spinnerLayout.gap = 1;

list.layout = spinnerLayout;
this.addChild(list);
raresn commented 5 years ago

We are in the middle of deploying a new update and would really appreciate some ideas on how to fix this. Thank you!

roipeker commented 5 years ago

Here's an easy fix for the bug (in both directions) without messing with the framework internals: Remember to remove the listener when you dispose/close the view.

list.addEventListener(TouchEvent.TOUCH, onSpinnerTouchValidate );

function onSpinnerTouchValidate(e:TouchEvent) {
            var t:Touch = e.getTouch(list, TouchPhase.ENDED);
            if (t && !list.isScrolling ) {
                    list.scrollToPosition(
                            Math.round(list.horizontalScrollPosition / list.horizontalScrollStep) * list.horizontalScrollStep,
                            Math.round(list.verticalScrollPosition / list.verticalScrollStep) * list.verticalScrollStep,
                            0.3);
            }
        }
esidegallery commented 5 years ago

Crazy! I was just about to report the exact same issue with SlideShowLayout. @roipeker, thanks for the nifty workaround.

raresn commented 5 years ago

It works! Thank you @roipeker ! You saved us a s#itload of time!

roipeker commented 5 years ago

Glad to be helpful guys.

esidegallery commented 5 years ago

Thanks Josh!