From 1df5dd2e4d6f9129cf495e9af612f4fc8bd6afda Mon Sep 17 00:00:00 2001 From: Paul Wisbey Date: Sat, 31 May 2014 12:09:21 +0900 Subject: [PATCH 1/1] ScrollView: Avoid unintentional contraints on X/Y properties [problem] Snap animation is not working in homescreen ScrollView [cause] Whilst the X/Y properties are animated, they are unintentionally constrained to match the position from previous pan [solution] More logic to ensure constraints are removed after pan finishes. --- .../scrollable/scroll-view/scroll-view-impl.cpp | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp b/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp index bff54c7..6cd1a37 100644 --- a/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp +++ b/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp @@ -2143,17 +2143,23 @@ void ScrollView::OnPan(PanGesture gesture) self.SetProperty( mPropertyScrollStartPagePosition, GetCurrentScrollPosition() ); // Update property: X & Y = Position (only when in panning mode - in snapping mode, X & Y are animated). - Constraint constraint = Constraint::New( mPropertyX, - LocalSource( mPropertyPosition ), - Source( self, mPropertyPanning ), - InternalXConstraint ); - mScrollMainInternalXConstraint = self.ApplyConstraint(constraint); + if( ! mScrollMainInternalXConstraint ) + { + Constraint constraint = Constraint::New( mPropertyX, + LocalSource( mPropertyPosition ), + Source( self, mPropertyPanning ), + InternalXConstraint ); + mScrollMainInternalXConstraint = self.ApplyConstraint( constraint ); + } + if( ! mScrollMainInternalYConstraint ) + { + Constraint constraint = Constraint::New( mPropertyY, + LocalSource( mPropertyPosition ), + Source( self, mPropertyPanning ), + InternalYConstraint ); + mScrollMainInternalYConstraint = self.ApplyConstraint( constraint ); + } - constraint = Constraint::New( mPropertyY, - LocalSource( mPropertyPosition ), - Source( self, mPropertyPanning ), - InternalYConstraint ); - mScrollMainInternalYConstraint = self.ApplyConstraint(constraint); // When panning we want to make sure overshoot values are affected by pre position and post position SetOvershootConstraintsEnabled(true); break; @@ -2174,6 +2180,8 @@ void ScrollView::OnPan(PanGesture gesture) // Remove X & Y position constraints as they are not required when we are not panning. self.RemoveConstraint(mScrollMainInternalXConstraint); self.RemoveConstraint(mScrollMainInternalYConstraint); + mScrollMainInternalXConstraint.Reset(); + mScrollMainInternalYConstraint.Reset(); break; } -- 2.7.4