-
-
Save ederchrono/a6e34dffb8ff1d372f3050dd1477f1db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inside methods | |
createReleaseAnimation() { | |
if(this.swipingLeft) { | |
if(this.nextImagePosition > HALF_WIDTH) { | |
// next image should be animated back to be offscreen | |
this.nextImageAnimatedX = this.nextImagePosition | |
return {nextImageAnimatedX: DEVICE_WIDTH} | |
} | |
// current image "copies" the nextImage position | |
this.currentImageAnimatedX = this.nextImagePosition | |
// the nextImage is sent offscreen | |
this.nextImageAnimatedX = DEVICE_WIDTH | |
// Change the image index to become the next image in the array | |
// images src attribute will update accordingly | |
this.currentImageIndex = this.nextImageIndex | |
return {currentImageAnimatedX: 0} | |
} | |
// swipe right | |
if(this.currentImagePosition < HALF_WIDTH) { | |
// current image should be animated back to center position | |
this.currentImageAnimatedX = this.currentImagePosition | |
return {currentImageAnimatedX: 0} | |
} | |
// the nextImage "copies" the currentImage position | |
this.nextImageAnimatedX = this.currentImagePosition | |
// the currentImage gets centered to become the prevImage | |
this.currentImageAnimatedX = 0 | |
// Change the image index to become the previous image in the array | |
this.currentImageIndex = this.previousImageIndex | |
return {nextImageAnimatedX: DEVICE_WIDTH} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment