forked from reya/gpui-native-kit
Fix shared element state across component instances
This commit is contained in:
@@ -135,16 +135,12 @@ impl RenderOnce for Slider {
|
||||
0.0
|
||||
};
|
||||
|
||||
// The track bounds, recorded by the overlay canvas each frame,
|
||||
// turn pointer positions into values inside the listeners.
|
||||
let bounds_cell = Rc::new(Cell::new(None::<Bounds<Pixels>>));
|
||||
// Dragging crosses frames, so it lives in keyed element state,
|
||||
// a per-render flag would reset when the owner's update repaints.
|
||||
let dragging = window.use_keyed_state("slider-dragging", cx, |_, _| false);
|
||||
// A held handle gives the arrow-key listener something to check focus against,
|
||||
// and the click-to-focus behavior a target.
|
||||
let focus_handle = gpui_native_utils::focus_handle(&self.id, window, cx);
|
||||
|
||||
let dragging =
|
||||
window.use_keyed_state((self.id.clone(), "slider-dragging"), cx, |_, _| false);
|
||||
|
||||
let set_value: ValueSetter = {
|
||||
let bounds_cell = bounds_cell.clone();
|
||||
let on_change = self.on_change.clone();
|
||||
|
||||
Reference in New Issue
Block a user