CosmicMind / Motion

A library used to create beautiful animations and transitions for iOS.

Home Page:http://cosmicmind.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with flickering on transitioning from VC

TheSwiftyCoder opened this issue · comments

Getting a huge flickering

I'm currently trying to transition from one VC1 to VC2 when a user clicks a cell. The transitions and their have been set to be the boxView cell of a collection view within VC1 to the background view of VC2. When I transition over to VC2 and back half of VC2 is missing from the transition. There's also an issue when I dismiss VC2 the boxView of VC1 collection view cell is 1/4 the size that it should be and shifted along the X axis.

VC1 didSelectCell code:

                    `if let cell = collectionView.cellForItem(at: indexPath) as? CourseCell {
		
		let cardData = "cell-\(indexPath.row)"
		cell.boxView.transition([.useNoSnapshot, .spring(stiffness: 250, damping: 25)])
		cell.boxView.motionIdentifier = cardData
		
		let vc = CourseViewController(nibName: CourseViewController.identifier, bundle: nil)
		vc.course = courses[indexPath.row]
		vc.isMotionEnabled = true
		vc.motionTransitionType = .none
		
		vc.view.motionIdentifier = cardData
		vc.view.transition([.source(cardData), .useNoSnapshot, .spring(stiffness: 250, damping: 25)])
		vc.lessonsTableView.motionIdentifier = "course-\(indexPath.row)"
		
		UIView.animate(withDuration: 0.2, delay: 0, options: .curveEaseIn, animations: {
			cell.boxView.transform = CGAffineTransform.init(scaleX: 0.95, y: 0.95)
		}) { _ in
			self.present(vc, animated: true)
			cell.boxView.transform = .identity
		}
	}`

VC1 cellForRowAt code:

            `cell.motionIdentifier = "cell-\(indexPath.row)"
	cell.boxView.motionIdentifier = "course-\(indexPath.row)"
	cell.transition([.fadeIn, .scale(1)])`

I've spent the passed couple of days trying to solve this and no luck.

Hey! I'd be happy to help. Please send over a project that reproduces the issue. Also, what version of iOS, Material, and Xcode are you using? Thank you!

@DanielDahan - Thanks, I managed to solve this with further trial and error. The configuration involved `.maskToBounds(), .cornerRadius(), .useScaleBasedSizeChange, + forceAnimate, to achieve the result.