/// Given an async `task` which draws `plugin`, activates the plugin in stages
/// to prevent screen shearing.  First, and plugin is appended ot the DOM with
/// opacity 0, then rendered.  After rendering, the previous plugin is removed
/// and the opacity is set back to 1.
///
/// # Arguments
/// - `viewer` the root `<perspective-viewer>` element.
/// - `plugin` the plugin custom element.
/// - `task` an async task which renders the plugin.
Given an async `task` which draws `plugin`, activates the plugin in stages
to prevent screen shearing.  First, and plugin is appended ot the DOM with
opacity 0, then rendered.  After rendering, the previous plugin is removed
and the opacity is set back to 1.
Given an async ` task ` which draws ` plugin ` activates the plugin in stages to prevent screen shearing . First and plugin is appended ot the DOM with opacity 0 then rendered . After rendering the previous plugin is removed and the opacity is set back to 1 .
pub async fn activate_plugin(
    viewer: &HtmlElement,
    plugin: &JsPerspectiveViewerPlugin,
    task: impl Future<Output = Result<JsValue, JsValue>>,
) -> Result<JsValue, JsValue> {
    let html_plugin = plugin.unchecked_ref::<HtmlElement>();
    if html_plugin.parent_node().is_none() {
        html_plugin.style().set_property("opacity", "0")?;
        viewer.append_child(html_plugin)?;
    }
    let result = task.await;
    let first_child = viewer.children().item(0).unwrap();
    if first_child != *plugin.unchecked_ref::<Element>() {
        viewer.remove_child(&first_child)?;
    }
    html_plugin.style().set_property("opacity", "1")?;
    result
}
pub async fn activate_plugin ( viewer : & HtmlElement , plugin : & JsPerspectiveViewerPlugin , task : impl Future < Output = Result < JsValue , JsValue > > , ) -> Result < JsValue , JsValue > { let html_plugin = plugin . unchecked_ref :: < HtmlElement > ( ) ; if html_plugin . parent_node ( ) . is_none ( ) { html_plugin . style ( ) . set_property ( " " , " " ) ? ; viewer . append_child ( html_plugin ) ? ; } let result = task . await ; let first_child = viewer . children ( ) . item ( 0 ) . unwrap ( ) ; if first_child != * plugin . unchecked_ref :: < Element > ( ) { viewer . remove_child ( & first_child ) ? ; } html_plugin . style ( ) . set_property ( " " , " " ) ? ; result }
Given an async `task` which draws `plugin`, activates the plugin in stages
to prevent screen shearing.
Given an async ` task ` which draws ` plugin ` activates the plugin in stages to prevent screen shearing .
viewer
&HtmlElement
the root `` element.
the root ` ` element .
plugin
&JsPerspectiveViewerPlugin
the plugin custom element.
the plugin custom element .
task
impl Future<Output = Result<JsValue, JsValue>>
an async task which renders the plugin.
an async task which renders the plugin .