pub fn pan_to_visible(&mut self, rect: Rect) -> bool {
        /// Given a position and the min and max edges of an axis,
        /// return a delta by which to adjust that axis such that the value
        /// falls between its edges.
        ///
        /// if the value already falls between the two edges, return 0.0.
        fn closest_on_axis(val: f64, min: f64, max: f64) -> f64 {
            assert!(min <= max);
            if val > min && val < max {
                0.0
            } else if val <= min {
                val - min
            } else {
                val - max
            }
        }

        // clamp the target region size to our own size.
        // this means we will show the portion of the target region that
        // includes the origin.
        let target_size = Size::new(
            rect.width().min(self.view_size.width),
            rect.height().min(self.view_size.height),
        );
        let rect = rect.with_size(target_size);

        let my_rect = self.view_rect();
        let x0 = closest_on_axis(rect.min_x(), my_rect.min_x(), my_rect.max_x());
        let x1 = closest_on_axis(rect.max_x(), my_rect.min_x(), my_rect.max_x());
        let y0 = closest_on_axis(rect.min_y(), my_rect.min_y(), my_rect.max_y());
        let y1 = closest_on_axis(rect.max_y(), my_rect.min_y(), my_rect.max_y());

        let delta_x = if x0.abs() > x1.abs() { x0 } else { x1 };
        let delta_y = if y0.abs() > y1.abs() { y0 } else { y1 };
        let new_origin = self.view_origin + Vec2::new(delta_x, delta_y);
        self.pan_to(new_origin)
    }
/// Pan the smallest distance that makes the target [`Rect`] visible.
///
/// If the target rect is larger than viewport size, we will prioritize
/// the region of the target closest to its origin.
Pan the smallest distance that makes the target [`Rect`] visible.
If the target rect is larger than viewport size, we will prioritize
the region of the target closest to its origin.
Pan the smallest distance that makes the target [ ` Rect ` ] visible . If the target rect is larger than viewport size we will prioritize the region of the target closest to its origin .
pub fn pan_to_visible(&mut self, rect: Rect) -> bool {
        /// Given a position and the min and max edges of an axis,
        /// return a delta by which to adjust that axis such that the value
        /// falls between its edges.
        ///
        /// if the value already falls between the two edges, return 0.0.
        fn closest_on_axis(val: f64, min: f64, max: f64) -> f64 {
            assert!(min <= max);
            if val > min && val < max {
                0.0
            } else if val <= min {
                val - min
            } else {
                val - max
            }
        }
        // clamp the target region size to our own size.
        // this means we will show the portion of the target region that
        // includes the origin.
        let target_size = Size::new(
            rect.width().min(self.view_size.width),
            rect.height().min(self.view_size.height),
        );
        let rect = rect.with_size(target_size);
        let my_rect = self.view_rect();
        let x0 = closest_on_axis(rect.min_x(), my_rect.min_x(), my_rect.max_x());
        let x1 = closest_on_axis(rect.max_x(), my_rect.min_x(), my_rect.max_x());
        let y0 = closest_on_axis(rect.min_y(), my_rect.min_y(), my_rect.max_y());
        let y1 = closest_on_axis(rect.max_y(), my_rect.min_y(), my_rect.max_y());
        let delta_x = if x0.abs() > x1.abs() { x0 } else { x1 };
        let delta_y = if y0.abs() > y1.abs() { y0 } else { y1 };
        let new_origin = self.view_origin + Vec2::new(delta_x, delta_y);
        self.pan_to(new_origin)
    }
pub fn pan_to_visible ( & mut self , rect : Rect ) -> bool { /// Given a position and the min and max edges of an axis, /// return a delta by which to adjust that axis such that the value /// falls between its edges. /// /// if the value already falls between the two edges, return 0.0. fn closest_on_axis ( val : f64 , min : f64 , max : f64 ) -> f64 { assert ! ( min max ) ; if val > min && val < max { 0.0 } else if val <= min { val - min } else { val - max } } // clamp the target region size to our own size. // this means we will show the portion of the target region that // includes the origin. let target_size = Size :: new ( rect . width ( ) . min ( self . view_size . width ) , rect . height ( ) . min ( self . view_size . height ) , ) ; let rect = rect . with_size ( target_size ) ; let my_rect = self . view_rect ( ) ; let x0 = closest_on_axis ( rect . min_x ( ) , my_rect . min_x ( ) , my_rect . max_x ( ) ) ; let x1 = closest_on_axis ( rect . max_x ( ) , my_rect . min_x ( ) , my_rect . max_x ( ) ) ; let y0 = closest_on_axis ( rect . min_y ( ) , my_rect . min_y ( ) , my_rect . max_y ( ) ) ; let y1 = closest_on_axis ( rect . max_y ( ) , my_rect . min_y ( ) , my_rect . max_y ( ) ) ; let delta_x = if x0 . abs ( ) > x1 . abs ( ) { x0 } else { x1 } ; let delta_y = if y0 . abs ( ) > y1 . abs ( ) { y0 } else { y1 } ; let new_origin = self . view_origin + Vec2 :: new ( delta_x , delta_y ) ; self . pan_to ( new_origin ) }
Pan the smallest distance that makes the target [`Rect`] visible.
Pan the smallest distance that makes the target [ ` Rect ` ] visible .
&mut self
rect
Rect
&mut self
rect
Rect