pub fn open(&self, target: web_sys::HtmlElement, resize_pubsub: Option<&PubSub<()>>) {
        if let Some(resize) = resize_pubsub {
            let this = self.clone();
            let target = target.clone();
            let anchor = self.anchor.clone();
            *self.resize_sub.borrow_mut() = Some(resize.add_listener(move |()| {
                let (top, left) = this.calc_anchor_position(&target);
                let msg = ModalMsg::SetPos {
                    top,
                    left,
                    visible: true,
                    rev_vert: anchor.get().is_rev_vert(),
                };

                this.root.borrow().as_ref().unwrap().send_message(msg);
            }));
        };

        if !self.is_open() {
            self.custom_element.blur().unwrap();
            let this = self.clone();
            spawn_local(async move {
                await_animation_frame().await.unwrap();
                target.class_list().add_1("modal-target").unwrap();
                let theme = get_theme(&target);
                this.open_within_viewport(target).await.unwrap();
                if let Some(theme) = theme {
                    this.custom_element.set_attribute("theme", &theme).unwrap();
                }
            });
        }
    }
/// Open this modal by attaching directly to `document.body` with position
/// absolutely positioned relative to an alread-connected `target`
/// element.
///
/// Because the Custom Element has a `blur` handler, we must invoke this
/// before attempting to re-parent the element.
Open this modal by attaching directly to `document.body` with position
absolutely positioned relative to an alread-connected `target`
element.

Because the Custom Element has a `blur` handler, we must invoke this
before attempting to re-parent the element.
Open this modal by attaching directly to ` document . body ` with position absolutely positioned relative to an alread - connected ` target ` element . Because the Custom Element has a ` blur ` handler we must invoke this before attempting to re - parent the element .
pub fn open(&self, target: web_sys::HtmlElement, resize_pubsub: Option<&PubSub<()>>) {
        if let Some(resize) = resize_pubsub {
            let this = self.clone();
            let target = target.clone();
            let anchor = self.anchor.clone();
            *self.resize_sub.borrow_mut() = Some(resize.add_listener(move |()| {
                let (top, left) = this.calc_anchor_position(&target);
                let msg = ModalMsg::SetPos {
                    top,
                    left,
                    visible: true,
                    rev_vert: anchor.get().is_rev_vert(),
                };
                this.root.borrow().as_ref().unwrap().send_message(msg);
            }));
        };
        if !self.is_open() {
            self.custom_element.blur().unwrap();
            let this = self.clone();
            spawn_local(async move {
                await_animation_frame().await.unwrap();
                target.class_list().add_1("modal-target").unwrap();
                let theme = get_theme(&target);
                this.open_within_viewport(target).await.unwrap();
                if let Some(theme) = theme {
                    this.custom_element.set_attribute("theme", &theme).unwrap();
                }
            });
        }
    }
pub fn open ( & self , target : web_sys :: HtmlElement , resize_pubsub : Option < & PubSub < ( ) > > ) { if let Some ( resize ) = resize_pubsub { let this = self . clone ( ) ; let target = target . clone ( ) ; let anchor = self . anchor . clone ( ) ; * self . resize_sub . borrow_mut ( ) = Some ( resize . add_listener ( move | ( ) | { let ( top , left ) = this . calc_anchor_position ( & target ) ; let msg = ModalMsg :: SetPos { top , left , visible : true , rev_vert : anchor . get ( ) . is_rev_vert ( ) , } ; this . root . borrow ( ) . as_ref ( ) . unwrap ( ) . send_message ( msg ) ; } ) ) ; } ; if ! self . is_open ( ) { self . custom_element . blur ( ) . unwrap ( ) ; let this = self . clone ( ) ; spawn_local ( async move { await_animation_frame ( ) . await . unwrap ( ) ; target . class_list ( ) . add_1 ( " " ) . unwrap ( ) ; let theme = get_theme ( & target ) ; this . open_within_viewport ( target ) . await . unwrap ( ) ; if let Some ( theme ) = theme { this . custom_element . set_attribute ( " " , & theme ) . unwrap ( ) ; } } ) ; } }
Open this modal by attaching directly to `document.body` with position
absolutely positioned relative to an alread-connected `target`
element.
Open this modal by attaching directly to ` document . body ` with position absolutely positioned relative to an alread - connected ` target ` element .
&self
target
web_sys::HtmlElement
resize_pubsub
Option<&PubSub<()>>
&self
target
web_sys::HtmlElement
resize_pubsub
Option<&PubSub<()>>