use crate::PositioningAlgorithm;
use crate::common::Position;
/// #### Description
/// Positions the child relative to the viewport rather than the parent element
///
pub struct AbsolutePositioning;
impl AbsolutePositioning {
/// #### Description
/// Creates an absolute positioning algorithm
///
/// #### Returns
/// [Box]<[AbsolutePositioning]> - An absolute positioning algorithm
///
pub fn new() -> Box<Self> {
return Box::new(Self);
}
}
impl PositioningAlgorithm for AbsolutePositioning {
fn calculate_position(&self, child_position: Position) -> Position {
return child_position;
}
fn set_parent_position(&mut self, _: Position) {
// Due to the way this positioning algorithm works, this is uneeded, but
// due to how the program is structured the positioning algorithm trait
// requires this function, so this functions body will remain empty
}
}