U
    Pe                     @   sP   d Z dZddlmZ ddlmZ ddlmZ ddlmZm	Z	 G dd deZ
d	S )
a7  
Scroll effect
=============

.. versionadded:: 1.7.0

Based on the :class:`~kivy.effects.kinetic` effect, the :class:`ScrollEffect`
will limit the movement to bounds determined by its :attr:`~ScrollEffect.min`
and :attr:`~ScrollEffect.max` properties. If the movement exceeds these
bounds, it will calculate the amount of :attr:`~ScrollEffect.overscroll` and
try to return to the value of one of the bounds.

This is very useful for implementing a scrolling list. We actually use this
class as a base effect for our :class:`~kivy.uix.scrollview.ScrollView` widget.

)ScrollEffect    )time)KineticEffect)Widget)NumericPropertyObjectPropertyc                       s   e Zd ZdZedZedZedZedZedZ	e
ddedZedZdd Zd	d
 Zd fdd	Zd fdd	Zd fdd	Z  ZS )r   zKScrollEffect class. See the module documentation for more information.
    Z20spr   NT)Z	allownoneZ	baseclassc                 C   s2   || _ d| _| jr.| jd d }t |fg| _dS )zs(internal) Reset the value and the velocity to the `pos`.
        Mostly used when the bounds are checked.
        r      N)valuevelocityhistoryr   )selfposval r   7/tmp/pip-unpacked-wheel-xzebddm3/kivy/effects/scroll.pyresetW   s
    zScrollEffect.resetc                 G   sn   | j }| j}||kr|| }}| j|k r@| j| | _| | n*| j|krb| j| | _| | n| j| _d S )N)minmaxr
   
overscrollr   scroll)r   argsZ
scroll_minZ
scroll_maxr   r   r   on_valuea   s    


zScrollEffect.on_valuec                    s   d| _ d| _tt| ||S )NTr   )	is_manualdisplacementsuperr   startr   r   t	__class__r   r   r   o   s    zScrollEffect.startc                    s2   |  j t|| jd d  7  _ tt| ||S )Nr   r	   )r   absr   r   r   updater   r   r   r   r"   t   s     zScrollEffect.updatec                    sN   d| _ |  jt|| jd d  7  _| j| jkr<d| _d S tt| ||S )NFr   r	   r   )	r   r   r!   r   drag_thresholdr   r   r   stopr   r   r   r   r$   x   s     zScrollEffect.stop)N)N)N)__name__
__module____qualname____doc__r   r#   r   r   r   r   r   r   Ztarget_widgetr   r   r   r   r"   r$   __classcell__r   r   r   r   r      s   			
r   N)r(   __all__r   Zkivy.effects.kineticr   Zkivy.uix.widgetr   Zkivy.propertiesr   r   r   r   r   r   r   <module>   s   