Here's a change to the scrollwidget that would make it snap to the edge of an album when left to spin on it's own. If the user clicks down and holds, it will still let you stop it anywhere, but when slowing down using friction, this will cause it to scroll to the next edge of a sprite before stopping:
Code:
def _apply_friction(self):
self.friction_c = self.friction_c + 1
if self.friction_c >= self.friction:
self.friction_c = 0
self.speed = self.speed - cmp(self.speed,0)
if abs(self.speed) < 3: # Special handling to snap to a sprite when we get slow
if abs(self.offset) > 5:
# still have a ways to go, so don't slow down yet
self.speed = self.speed + cmp(self.speed,0)
else:
# Just snap to the edge
self.speed = 0
self.offset = 0
def _apply_friction(self): self.friction_c = self.friction_c + 1 if self.friction_c >= self.friction: self.friction_c = 0 self.speed = self.speed - cmp(self.speed,0) if abs(self.speed) < 3: # Special handling to snap to a sprite when we get slow if abs(self.offset) > 5: # still have a ways to go, so don't slow down yet self.speed = self.speed + cmp(self.speed,0) else: # Just snap to the edge self.speed = 0 self.offset = 0