This repository has been archived on 2024-12-22. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2024-12-22/mockenv/lib/python3.6/site-packages/kivy/effects/opacityscroll.py
2022-07-22 16:13:59 +05:30

28 lines
838 B
Python

'''
Opacity scroll effect
=====================
Based on the :class:`~kivy.effects.damped.DampedScrollEffect`, this one will
also decrease the opacity of the target widget during the overscroll.
'''
__all__ = ('OpacityScrollEffect', )
from kivy.effects.dampedscroll import DampedScrollEffect
class OpacityScrollEffect(DampedScrollEffect):
'''OpacityScrollEffect class. Uses the overscroll
information to reduce the opacity of the scrollview widget. When the user
stops the drag, the opacity is set back to 1.
'''
def on_overscroll(self, *args):
if self.target_widget and self.target_widget.height != 0:
alpha = (1.0 -
abs(self.overscroll / float(self.target_widget.height)))
self.target_widget.opacity = min(1, alpha)
self.trigger_velocity_update()