Ejemplo n.º 1
0
        private void Heroescollectionview_Scrolled(object sender, ItemsViewScrolledEventArgs e)
        {
            var line = e.CenterItemIndex;

            var transY = Convert.ToInt32(SearchView.TranslationY);

            if (transY == 0 &&
                e.VerticalDelta > 15)
            {
                var trans = SearchView.Height + SearchView.Margin.Top;
                // need contentpage var safeInsets = On<Xamarin.Forms.PlatformConfiguration.iOS>().SafeAreaInsets();

                ImageService.Instance.SetPauseWork(false);

                Task.WhenAll(
                    SearchView.TranslateTo(0, -(trans + 8), 250, Easing.CubicIn),
                    SearchView.FadeTo(0, 200));
            }
            else if (transY != 0 &&
                     e.VerticalDelta < 0 &&
                     Math.Abs(e.VerticalDelta) > 10)
            {
                Task.WhenAll(
                    SearchView.TranslateTo(0, 0, 250, Easing.CubicOut),
                    SearchView.FadeTo(1, 200));
                ImageService.Instance.SetPauseWork(true);
            }

            //else if(transY == 0 &&
            //        e.VerticalDelta <=1)
            //{
            //    Task.WhenAll(
            //        SearchView.TranslateTo(0, 0, 250, Easing.CubicOut),
            //        SearchView.FadeTo(1, 200));
            //}

            //precisão maior para validar.
            bool IsScrollUp = e.VerticalDelta < 0;

            if (IsScrollUp)
            {
                ImageService.Instance.SetPauseWork(true);
            }
            else
            {
                ImageService.Instance.SetPauseWork(false);
            }
        }