class CheckInViewController extends TimeCardsViewController { viewDidLoad() { //this.iconRight = TimeCards. this.checkInSlider.addEventListener("change", this.onCheckInSliderChanged.bind(this)); this.isCheckedIn = false; } viewWillAppear() { } viewDidDisappear() { } onCheckInSliderInput(event) { if (!this.waitingForRelease) { this.waitingForRelease = true; this.valueBeforeDrag = this.isCheckedIn ? 1 : 0; } } onCheckInSliderChanged(event) { this.waitingForRelease = false; const distance = this.checkInSlider.value - this.valueBeforeDrag; if (distance > 0.3) { this.setState(true); } else if (distance < -0.3) { this.setState(false); } else { this.startAnimation(); } } setState(isCheckedIn) { this.isCheckedIn = isCheckedIn; this.startAnimation(); } startAnimation() { this.animationInterval = setInterval(this.animateState.bind(this), 16); } animateState() { this.checkInSlider.value = parseFloat(this.checkInSlider.value) + parseFloat(this.checkInSlider.step) * 500 * (this.isCheckedIn ? 1 : -1); if (this.checkInSlider.value <= 0 || this.checkInSlider.value >= 1) { clearInterval(this.animationInterval); } } } UIKit.registerViewControllerType(CheckInViewController);