@@ -219,29 +219,34 @@ function MetaBoxesMain( { isLegacy } ) {
219
219
}
220
220
} ;
221
221
const [ isDragging , setIsDragging ] = useState ( false ) ;
222
- const bindDragGesture = useDrag ( ( { movement, first, last, memo } ) => {
223
- if ( first ) {
224
- setIsDragging ( true ) ;
225
- if ( heightRef . current === undefined ) {
226
- const fromHeight = metaBoxesMainRef . current . offsetHeight ;
227
- return { fromHeight } ;
222
+ const bindDragGesture = useDrag (
223
+ ( { movement, first, last, memo, swipe } ) => {
224
+ if ( first ) {
225
+ setIsDragging ( true ) ;
226
+ if ( heightRef . current === undefined ) {
227
+ const fromHeight = metaBoxesMainRef . current . offsetHeight ;
228
+ return { fromHeight } ;
229
+ }
230
+ if ( heightRef . current > max ) {
231
+ // Starts from max in case shortening the window has imposed it.
232
+ return { fromHeight : max } ;
233
+ }
234
+ return { fromHeight : heightRef . current } ;
228
235
}
229
- if ( heightRef . current > max ) {
230
- // Starts from max in case shortening the window has imposed it.
231
- return { fromHeight : max } ;
236
+ const [ , yMovement ] = movement ;
237
+ if ( ! first && ! last ) {
238
+ applyHeight ( memo . fromHeight - yMovement ) ;
239
+ return memo ;
240
+ }
241
+ setIsDragging ( false ) ;
242
+ const [ , swipeY ] = swipe ;
243
+ if ( swipeY ) {
244
+ applyHeight ( swipeY === - 1 ? max : min , true ) ;
245
+ } else if ( yMovement !== 0 ) {
246
+ applyHeight ( heightRef . current , true ) ;
232
247
}
233
- return { fromHeight : heightRef . current } ;
234
- }
235
- const [ , yMovement ] = movement ;
236
- if ( ! first && ! last ) {
237
- applyHeight ( memo . fromHeight - yMovement ) ;
238
- return memo ;
239
- }
240
- setIsDragging ( false ) ;
241
- if ( yMovement !== 0 ) {
242
- applyHeight ( heightRef . current , true ) ;
243
248
}
244
- } ) ;
249
+ ) ;
245
250
246
251
if ( ! hasAnyVisible ) {
247
252
return ;
0 commit comments