private void MovePrevious() { if (this.AnimationIsRunning("TransitionAnimation")) { return; } var screenWidthPixels = ImageSkiaCanvas.CanvasSize.Width; // load up the image we are animating in var screenRect = new SKRect(0, 0, ImageSkiaCanvas.CanvasSize.Width, ImageSkiaCanvas.CanvasSize.Height); offscreenBitmap = CreateAspectCorrectedBitmap(viewModel.PreviousLocation.ImageResource, screenRect); offscreenHeading.Text = viewModel.PreviousLocation.Title; offscreenBody.Text = viewModel.PreviousLocation.Description; offscreenHeading.Opacity = 0; offscreenBody.Opacity = 0; // make sure we are setting the starting locations; bandTranslationValues = GetInitializedArray <double>(numberOfBands, 0); incomingBandTranslationValues = GetInitializedArray <double>(numberOfBands, screenWidthPixels); var parentAnimation = new Animation(); AddChildAnimationForOutgoing(parentAnimation, Direction.Previous); AddChildAnimationsForIncoming(parentAnimation, Direction.Previous); AddChildAnimationsForText(parentAnimation, Direction.Previous); var skiaAnimation = new Animation( callback: v => { isAnimating = true; ImageSkiaCanvas.InvalidateSurface(); }, start: 0, end: 1, easing: Easing.Linear); parentAnimation.Add(0, 1, skiaAnimation); parentAnimation.Commit(this, "TransitionAnimation", 16, 2000, Easing.SinInOut, (v, c) => { isAnimating = false; viewModel.MovePrevious(); CycleElements(); currentBitmap = offscreenBitmap; SideBarCanvas.InvalidateSurface(); }); }
private void SwipeGestureRecognizer_SwipedToRight(object sender, SwipedEventArgs e) { // see if the animation is running if (this.AnimationIsRunning("TransitionAnimation")) { return; } RightSwap = true; // update the elements UpdateOffScreenElements(viewModel.PreviousLocation); // move the current stuff off the screen var onscreenHeadingSlideOut = new Animation(v => currentHeading.TranslationX = v, 0, this.Width, Easing.SinIn); var onscreenHeadingFade = new Animation(v => currentHeading.Opacity = v, 1, 0, Easing.SinIn); var onscreenBodySlideOut = new Animation(v => currentBody.TranslationX = v, 0, this.Width, Easing.SinIn); var onscreenBodyFade = new Animation(v => currentBody.Opacity = v, 1, 0, Easing.SinIn); // move the offscreen stuff onto the screen var offscreenHeadingSlideIn = new Animation(v => offscreenHeading.TranslationX = v, -this.Width, 0, Easing.SinOut); var offscreenHeadingFadeIn = new Animation(v => offscreenHeading.Opacity = v, 0, 1, Easing.SinOut); var offscreenBodySlideIn = new Animation(v => offscreenBody.TranslationX = v, -this.Width, 0, Easing.SinOut); var offscreenBodyFade = new Animation(v => offscreenBody.Opacity = v, 0, 1, Easing.SinIn); // animation for skia elements var skiaAnimation = new Animation( callback: v => { transitionValue = v; ImageSkiaCanvas.InvalidateSurface(); }, start: 2, end: 0, easing: Easing.SinInOut); var outgoingImageAnimation = new Animation( callback: v => { outgoingOffset = v; }, start: 0, end: this.Width, easing: Easing.CubicInOut); var parentAnimation = new Animation(); // outgoing child animations parentAnimation.Add(0, 1, onscreenHeadingSlideOut); parentAnimation.Add(0, .5, onscreenHeadingFade); parentAnimation.Add(.2, 1, onscreenBodySlideOut); parentAnimation.Add(0, 1, onscreenBodyFade); // inbound child animations parentAnimation.Add(.2, 1, offscreenHeadingSlideIn); parentAnimation.Add(.2, 1, offscreenHeadingFadeIn); parentAnimation.Add(.4, 1, offscreenBodySlideIn); parentAnimation.Add(.4, 1, offscreenBodyFade); // add skia animations parentAnimation.Add(0, 1, skiaAnimation); parentAnimation.Add(.5, 1, outgoingImageAnimation); parentAnimation.Commit(this, "TransitionAnimation", 16, 750, null, (v, c) => { viewModel.MovePrevious(); CycleElements(); currentBitmap = offscreenBitmap; }); }