Created
November 21, 2023 17:13
-
-
Save kengoon/b162030a9088bc21dc8db5844c94271b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.effects.scroll import ScrollEffect | |
from kivy.properties import NumericProperty | |
from kivy.effects.dampedscroll import DampedScrollEffect | |
class LowerScrollEffect(ScrollEffect): | |
friction = NumericProperty(0.027) | |
def on_overscroll(self, *args): | |
sv = self.target_widget.parent | |
if hasattr(sv, "on_overscroll"): | |
sv.dispatch("on_overscroll", *args) | |
if args[1] < 0: | |
sv.dispatch("on_overscroll_down") | |
else: | |
sv.dispatch("on_overscroll_up") | |
class HardStopScrollEffect(LowerScrollEffect): | |
def stop(self, val, t=None): | |
return super().stop(val, t=0.01) | |
class LowerDampedScrollEffect(DampedScrollEffect): | |
friction = NumericProperty(.03) | |
def on_overscroll(self, *args): | |
super().on_overscroll(*args) | |
sv = self.target_widget.parent | |
if hasattr(sv, "on_overscroll"): | |
sv.dispatch("on_overscroll", *args) | |
if args[1] < 0: | |
sv.dispatch("on_overscroll_down") | |
else: | |
sv.dispatch("on_overscroll_up") | |
class HardStopDampedScrollEffect(LowerDampedScrollEffect): | |
def stop(self, val, t=None): | |
return super().stop(val, t=0.01) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for making this