bool OnTouchEvent( Actor actor, const TouchEvent& event ) { if( 1u == event.GetPointCount() ) { const TouchPoint::State state = event.GetPoint(0u).state; // Clamp to integer values; this is to reduce flicking due to pixel misalignment const float localPoint = static_cast<float>( static_cast<int>( event.GetPoint( 0 ).local.y ) ); if( TouchPoint::Down == state ) { mLastPoint = localPoint; mAnimation = Animation::New( 0.25f ); } else if( TouchPoint::Motion == state ) { if( mAnimation ) { mAnimation.AnimateBy( Property(mTableView, Actor::Property::POSITION), Vector3( 0.f, localPoint - mLastPoint, 0.f ), AlphaFunction::LINEAR ); mAnimation.Play(); mLastPoint = localPoint; } } } return true; }
bool ScrollViewSlideEffect::OnScrollTouched(Actor actor, const TouchEvent& event) { // Ignore events with multiple-touch points if (event.GetPointCount() != 1) { return false; } if (event.GetPoint(0).state == TouchPoint::Down) { const TouchPoint& point = event.GetPoint(0); Vector3 touchPosition(point.local - Stage::GetCurrent().GetSize() * 0.5f); Vector3 scrollPosition = GetScrollView().GetCurrentScrollPosition(); GetScrollView().SetProperty(mPropertyReference, scrollPosition + touchPosition + mDelayReferenceOffset); } return false; }