File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,22 @@ class ListContainer extends PureComponent {
116116 isNeedSpring : false
117117 } )
118118 }
119+ /**
120+ * 拖拽的缓动公式 - easeOutSine
121+ * Link http://easings.net/zh-cn#
122+ * t: current time(当前时间);
123+ * b: beginning value(初始值);
124+ * c: change in value(变化量);
125+ * d: duration(持续时间)。
126+ */
127+ easing = ( distance ) => {
128+ var t = distance ;
129+ var b = 0 ;
130+ var d = this . props . screenWidth ; // 允许拖拽的最大距离
131+ var c = d / 2.5 ; // 提示标签最大有效拖拽距离
132+
133+ return c * Math . sin ( t / d * ( Math . PI / 2 ) ) + b ;
134+ }
119135
120136 handleStart = ( ) => {
121137 console . info ( "ListContainer handleStart" )
@@ -127,7 +143,11 @@ class ListContainer extends PureComponent {
127143
128144 handleMove = ( diffX ) => {
129145 console . info ( "ListContainer handleStart diffX = %s" , diffX ) ;
130-
146+ if ( this . state . left >= 0 && diffX > 0 ) {
147+ diffX = this . easing ( diffX ) ;
148+ } else if ( this . state . left <= - this . maxLeft && diffX < 0 ) {
149+ diffX = - this . easing ( - diffX ) ;
150+ }
131151 this . setState ( {
132152 left : this . startLeft + diffX ,
133153 isNeedSpring : false
You can’t perform that action at this time.
0 commit comments