protected override void OnElementChanged(VisualElementChangedEventArgs e) { base.OnElementChanged(e); if (this.NativeView == null) { return; } //Accessing page numbers from the ScrollView abstraction renderer AnimatedScrollView animatedScrollView = (AnimatedScrollView)Element; _pages = animatedScrollView.NumberOfPage; nativeScrollView = (UIScrollView)this.NativeView; nativeScrollView.ContentSize = new CGSize(_pages * (float)this.NativeView.Frame.Width, (float)this.NativeView.Frame.Height); //TODO: Put these 2 parameters into the Abstraction renderer nativeScrollView.PagingEnabled = true; nativeScrollView.ShowsHorizontalScrollIndicator = false; // _isAtEnd = false; Animator = new Animator(); ScrollView = new UIScrollView(nativeScrollView.Bounds); ScrollView.Scrolled += (sender, args) => { Animator.Animate(Convert.ToInt32(ScrollView.ContentOffset.X)); _isAtEnd = ScrollView.ContentOffset.X >= MaxContentOffsetXForScrollView(ScrollView); //animatedScrolledService = ScrollView.Delegate; if (_isAtEnd && this.RespondsToSelector(new Selector("AnimatedScrollViewControllerDidScrollToEnd:"))) { //animatedScrolledService.AnimatedScrollViewControllerDidScrollToEnd(this); } }; ScrollView.ScrollAnimationEnded += (sender, args) => { //WeakDelegate = scrollView.Delegate; //animatedScrolledService = ScrollView.Delegate; if (_isAtEnd && this.RespondsToSelector(new Selector("AnimatedScrollViewControllerDidEndDraggingAtEnd:"))) { //animatedScrolledService.AnimatedScrollViewControllerDidEndDraggingAtEnd(this); } }; nativeScrollView.Add(ScrollView); }
public XFScrollViewSamplePage() { InitializeComponent(); var animatedView = new AnimatedView(); animatedView.BackgroundColor = Color.Black; animatedView.WidthRequest = 50; animatedView.HeightRequest = 50; var scrollView = new AnimatedScrollView(); scrollView.NumberOfPage = 2; scrollView.Content = new StackLayout { Children = { animatedView } }; //Animations //var alphaAnimation = new CrossScrollViewAnimations(); //Animator.Add var alphaAnimation = CrossScrollViewAnimations.Current.AlphaAnimation(animatedView, 1); var animator = new Animator(); animator.AddAnimation(alphaAnimation); alphaAnimation.AddKeyFrame(new AnimationFrame() { Time = TimeForPage(1), Alpha = 0.0f }); alphaAnimation.AddKeyFrame(new AnimationFrame() { Time = TimeForPage(2), Alpha = 1.0f }); }