@@ -428,8 +428,6 @@ fn run_app_inner(
428428 wire_save_settings_now ( & window, included_dirs. clone ( ) , excluded_dirs. clone ( ) , referenced_dirs. clone ( ) ) ;
429429
430430 let gallery_momentum: Rc < std:: cell:: RefCell < f32 > > = Rc :: new ( std:: cell:: RefCell :: new ( 0.0 ) ) ;
431- let list_momentum: Rc < std:: cell:: RefCell < f32 > > = Rc :: new ( std:: cell:: RefCell :: new ( 0.0 ) ) ;
432- let list_max_scroll: Rc < std:: cell:: RefCell < f32 > > = Rc :: new ( std:: cell:: RefCell :: new ( 0.0 ) ) ;
433431
434432 {
435433 let weak_g = window. as_weak ( ) ;
@@ -455,92 +453,33 @@ fn run_app_inner(
455453 } ) ;
456454 }
457455
458- {
459- let weak_l = window. as_weak ( ) ;
460- let mom_l = Rc :: clone ( & list_momentum) ;
461- let max_l = Rc :: clone ( & list_max_scroll) ;
462- window. global :: < AppState > ( ) . on_list_swiped ( move |total_delta, vel_px| {
463- if let Some ( win) = weak_l. upgrade ( ) {
464- let current = win. global :: < AppState > ( ) . get_list_scroll_y ( ) ;
465- let max_scroll = win. global :: < AppState > ( ) . get_list_max_scroll_f ( ) ;
466-
467- let new_y = ( current + total_delta) . clamp ( -max_scroll, 0.0 ) ;
468- win. global :: < AppState > ( ) . set_list_scroll_y ( new_y) ;
469-
470- // Keep a local copy so the momentum timer doesn't need an extra
471- // AppState round-trip every frame.
472- * max_l. borrow_mut ( ) = max_scroll;
473-
474- const VEL_THRESHOLD : f32 = 4.0 ;
475- * mom_l. borrow_mut ( ) = if vel_px. abs ( ) < VEL_THRESHOLD { 0.0 } else { vel_px * 1.5 } ;
476- }
477- } ) ;
478- }
479-
480- {
481- let mom_l = Rc :: clone ( & list_momentum) ;
482- window. global :: < AppState > ( ) . on_list_stop_momentum ( move || {
483- * mom_l. borrow_mut ( ) = 0.0 ;
484- } ) ;
485- }
486-
487456 let scroll_timer = Timer :: default ( ) ;
488457 {
489458 let weak_sc = window. as_weak ( ) ;
490459 let mom_sc = Rc :: clone ( & gallery_momentum) ;
491- let list_mom_sc = Rc :: clone ( & list_momentum) ;
492- let list_max_sc = Rc :: clone ( & list_max_scroll) ;
493460 scroll_timer. start ( TimerMode :: Repeated , std:: time:: Duration :: from_millis ( 16 ) , move || {
494461 // ── Gallery fling ─────────────────────────────────────────────
495- {
496- let mut mom = mom_sc. borrow_mut ( ) ;
497- if mom. abs ( ) > 0.3 {
498- if let Some ( win) = weak_sc. upgrade ( ) {
499- let current = win. global :: < AppState > ( ) . get_gallery_scroll_y ( ) ;
500- let max_scroll = win. global :: < AppState > ( ) . get_gallery_max_scroll_f ( ) ;
501- let new_y = ( current + * mom) . clamp ( -max_scroll, 0.0 ) ;
502- win. global :: < AppState > ( ) . set_gallery_scroll_y ( new_y) ;
503-
504- * mom *= 0.95 ;
505-
506- if new_y >= 0.0 || new_y <= -max_scroll {
507- * mom = 0.0 ;
508- }
509- }
510- } else if let Some ( win) = weak_sc. upgrade ( ) {
511- let max_s = win. global :: < AppState > ( ) . get_gallery_max_scroll_f ( ) ;
512- let cur = win. global :: < AppState > ( ) . get_gallery_scroll_y ( ) ;
513- if max_s > 0.0 && cur < -max_s {
514- win. global :: < AppState > ( ) . set_gallery_scroll_y ( -max_s) ;
515- } else if cur > 0.0 {
516- win. global :: < AppState > ( ) . set_gallery_scroll_y ( 0.0 ) ;
462+ let mut mom = mom_sc. borrow_mut ( ) ;
463+ if mom. abs ( ) > 0.3 {
464+ if let Some ( win) = weak_sc. upgrade ( ) {
465+ let current = win. global :: < AppState > ( ) . get_gallery_scroll_y ( ) ;
466+ let max_scroll = win. global :: < AppState > ( ) . get_gallery_max_scroll_f ( ) ;
467+ let new_y = ( current + * mom) . clamp ( -max_scroll, 0.0 ) ;
468+ win. global :: < AppState > ( ) . set_gallery_scroll_y ( new_y) ;
469+
470+ * mom *= 0.95 ;
471+
472+ if new_y >= 0.0 || new_y <= -max_scroll {
473+ * mom = 0.0 ;
517474 }
518475 }
519- }
520- // ── List fling ────────────────────────────────────────────────
521- {
522- let mut mom = list_mom_sc. borrow_mut ( ) ;
523- if mom. abs ( ) > 0.3 {
524- if let Some ( win) = weak_sc. upgrade ( ) {
525- let current = win. global :: < AppState > ( ) . get_list_scroll_y ( ) ;
526- let max_scroll = * list_max_sc. borrow ( ) ;
527- let new_y = ( current + * mom) . clamp ( -max_scroll, 0.0 ) ;
528- win. global :: < AppState > ( ) . set_list_scroll_y ( new_y) ;
529-
530- * mom *= 0.95 ;
531-
532- if new_y >= 0.0 || new_y <= -max_scroll {
533- * mom = 0.0 ;
534- }
535- }
536- } else if let Some ( win) = weak_sc. upgrade ( ) {
537- let max_s = * list_max_sc. borrow ( ) ;
538- let cur = win. global :: < AppState > ( ) . get_list_scroll_y ( ) ;
539- if max_s > 0.0 && cur < -max_s {
540- win. global :: < AppState > ( ) . set_list_scroll_y ( -max_s) ;
541- } else if cur > 0.0 {
542- win. global :: < AppState > ( ) . set_list_scroll_y ( 0.0 ) ;
543- }
476+ } else if let Some ( win) = weak_sc. upgrade ( ) {
477+ let max_s = win. global :: < AppState > ( ) . get_gallery_max_scroll_f ( ) ;
478+ let cur = win. global :: < AppState > ( ) . get_gallery_scroll_y ( ) ;
479+ if max_s > 0.0 && cur < -max_s {
480+ win. global :: < AppState > ( ) . set_gallery_scroll_y ( -max_s) ;
481+ } else if cur > 0.0 {
482+ win. global :: < AppState > ( ) . set_gallery_scroll_y ( 0.0 ) ;
544483 }
545484 }
546485 } ) ;
0 commit comments