DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ItemView, Toolkit::Scrollable, NULL)
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "layout-position", FLOAT, LAYOUT_POSITION)
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "scroll-speed", FLOAT, SCROLL_SPEED)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "layoutPosition", FLOAT, LAYOUT_POSITION)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "scrollSpeed", FLOAT, SCROLL_SPEED)
DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "overshoot", FLOAT, OVERSHOOT)
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "scroll-direction", VECTOR2, SCROLL_DIRECTION)
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "layout-orientation", INTEGER, LAYOUT_ORIENTATION)
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "scroll-content-size", FLOAT, SCROLL_CONTENT_SIZE)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "scrollDirection", VECTOR2, SCROLL_DIRECTION)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "layoutOrientation", INTEGER, LAYOUT_ORIENTATION)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "scrollContentSize", FLOAT, SCROLL_CONTENT_SIZE)
-DALI_SIGNAL_REGISTRATION( Toolkit, ItemView, "layout-activated", LAYOUT_ACTIVATED_SIGNAL )
+DALI_SIGNAL_REGISTRATION( Toolkit, ItemView, "layoutActivated", LAYOUT_ACTIVATED_SIGNAL )
DALI_TYPE_REGISTRATION_END()
ItemView::ItemView(ItemFactory& factory)
: Scrollable( ControlBehaviour( DISABLE_SIZE_NEGOTIATION | REQUIRES_WHEEL_EVENTS | REQUIRES_KEYBOARD_NAVIGATION_SUPPORT ) ),
mItemFactory(factory),
+ mItemsParentOrigin(ParentOrigin::CENTER),
+ mItemsAnchorPoint(AnchorPoint::CENTER),
+ mTotalPanDisplacement(Vector2::ZERO),
mActiveLayout(NULL),
- mAnimatingOvershootOn(false),
- mAnimateOvershootOff(false),
- mAnchoringEnabled(false),
mAnchoringDuration(DEFAULT_ANCHORING_DURATION),
mRefreshIntervalLayoutPositions(0.0f),
- mRefreshOrderHint(true/*Refresh item 0 first*/),
mMinimumSwipeSpeed(DEFAULT_MINIMUM_SWIPE_SPEED),
mMinimumSwipeDistance(DEFAULT_MINIMUM_SWIPE_DISTANCE),
mWheelScrollDistanceStep(0.0f),
mScrollDistance(0.0f),
mScrollSpeed(0.0f),
- mTotalPanDisplacement(Vector2::ZERO),
mScrollOvershoot(0.0f),
- mIsFlicking(false),
mGestureState(Gesture::Clear),
+ mAnimatingOvershootOn(false),
+ mAnimateOvershootOff(false),
+ mAnchoringEnabled(false),
+ mRefreshOrderHint(true/*Refresh item 0 first*/),
+ mIsFlicking(false),
mAddingItems(false),
mRefreshEnabled(true),
- mItemsParentOrigin( ParentOrigin::CENTER),
- mItemsAnchorPoint( AnchorPoint::CENTER)
+ mInAnimation(false)
{
}
}
mScrollOvershoot = CalculateScrollOvershoot();
- self.SetProperty( Toolkit::ItemView::Property::OVERSHOOT, mScrollOvershoot );
+
+ // If the view is moved in a direction against the overshoot indicator, then the indicator should be animated off.
+ // First make sure we are not in an animation, otherwise a previously started
+ // off-animation will be overwritten as the user continues scrolling.
+ if( !mInAnimation )
+ {
+ // Check if the movement is against the current overshoot amount (if we are currently displaying the indicator).
+ if( ( ( mScrollOvershoot > Math::MACHINE_EPSILON_0 ) && ( mScrollDistance < -Math::MACHINE_EPSILON_0 ) ) ||
+ ( ( mScrollOvershoot < Math::MACHINE_EPSILON_0 ) && ( mScrollDistance > Math::MACHINE_EPSILON_0 ) ) )
+ {
+ // The user has moved against the indicator direction.
+ // First, we reset the total displacement. This means the overshoot amount will become zero the next frame,
+ // and if the user starts dragging in the overshoot direction again, the indicator will appear once more.
+ mTotalPanDisplacement = Vector2::ZERO;
+ // Animate the overshoot indicator off.
+ AnimateScrollOvershoot( 0.0f, false );
+ }
+ else
+ {
+ // Only set the property directly if we are not animating the overshoot away,
+ // as otherwise this will overwrite the animation generated value.
+ self.SetProperty( Toolkit::ItemView::Property::OVERSHOOT, mScrollOvershoot );
+ }
+ }
}
break;
{
AnimateScrollOvershoot(0.0f);
}
+ mInAnimation = false;
}
void ItemView::ScrollToItem(unsigned int itemId, float durationSeconds)
duration = mOvershootOverlay.GetCurrentSize().height * (animatingOn ? (1.0f - fabsf(currentOvershoot)) : fabsf(currentOvershoot)) / mOvershootAnimationSpeed;
}
+ // Mark the animation as in progress to prevent manual property sets overwriting it.
+ mInAnimation = true;
+ mAnimatingOvershootOn = animatingOn;
RemoveAnimation(mScrollOvershootAnimation);
mScrollOvershootAnimation = Animation::New(duration);
mScrollOvershootAnimation.FinishedSignal().Connect(this, &ItemView::OnOvershootOnFinished);
mScrollOvershootAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::OVERSHOOT), overshootAmount, TimePeriod(0.0f, duration) );
mScrollOvershootAnimation.Play();
-
- mAnimatingOvershootOn = animatingOn;
}
else
{