Search in sources :

Example 1 with Animation

use of com.google.gwt.animation.client.Animation in project rstudio by rstudio.

the class SlideLabel method hide.

public void hide(final Command executeOnComplete) {
    stopCurrentAnimation();
    final int height = curtain_.getOffsetHeight();
    currentAnimation_ = new Animation() {

        @Override
        protected void onUpdate(double progress) {
            setHeight(height * (1 - progress));
        }

        @Override
        protected void onComplete() {
            currentAnimation_ = null;
            super.onComplete();
            setVisible(false);
            if (executeOnComplete != null)
                executeOnComplete.execute();
        }
    };
    currentAnimation_.run(ANIM_MILLIS);
}
Also used : Animation(com.google.gwt.animation.client.Animation)

Example 2 with Animation

use of com.google.gwt.animation.client.Animation in project rstudio by rstudio.

the class PaneManager method horizontalResizeAnimation.

private Animation horizontalResizeAnimation(final double start, final double end, final Command afterComplete) {
    return new Animation() {

        @Override
        protected void onUpdate(double progress) {
            double size = (1 - progress) * start + progress * end;
            panel_.setWidgetSize(right_, size);
        }

        @Override
        protected void onStart() {
            isAnimating_ = true;
            super.onStart();
        }

        @Override
        protected void onComplete() {
            isAnimating_ = false;
            panel_.onSplitterResized(new SplitterResizedEvent());
            super.onComplete();
            if (afterComplete != null)
                afterComplete.execute();
        }
    };
}
Also used : SplitterResizedEvent(com.google.gwt.user.client.ui.SplitterResizedEvent) Animation(com.google.gwt.animation.client.Animation)

Example 3 with Animation

use of com.google.gwt.animation.client.Animation in project kie-wb-common by kiegroup.

the class ShowcaseEntryPoint method hideLoadingPopup.

// Fade out the "Loading application" pop-up
private void hideLoadingPopup() {
    final Element e = RootPanel.get("loading").getElement();
    new Animation() {

        @Override
        protected void onUpdate(double progress) {
            e.getStyle().setOpacity(1.0 - progress);
        }

        @Override
        protected void onComplete() {
            e.getStyle().setVisibility(Style.Visibility.HIDDEN);
        }
    }.run(500);
}
Also used : Element(com.google.gwt.dom.client.Element) Animation(com.google.gwt.animation.client.Animation)

Example 4 with Animation

use of com.google.gwt.animation.client.Animation in project webprotege by protegeproject.

the class DiscussionThreadListViewImpl method hideDiscussionThreadView.

@Override
public void hideDiscussionThreadView(DiscussionThreadView threadView) {
    if (threadViews.remove(threadView)) {
        Animation animation = new Animation() {

            @Override
            protected void onUpdate(double progress) {
                double opacity = 1 - (progress);
                final Element element = threadView.asWidget().getElement();
                element.getStyle().setOpacity(opacity);
                final double height = element.getClientHeight();
                if (progress == 1) {
                    Animation slideAnimation = new Animation() {

                        @Override
                        protected void onUpdate(double progress) {
                            double slideHeight = height * (1 - progress);
                            element.getStyle().setHeight((int) slideHeight, Style.Unit.PX);
                            if (progress == 1) {
                                threadContainer.remove(threadView);
                            }
                        }
                    };
                    slideAnimation.run(500);
                }
            }
        };
        animation.run(400);
    }
}
Also used : Element(com.google.gwt.user.client.Element) Animation(com.google.gwt.animation.client.Animation)

Example 5 with Animation

use of com.google.gwt.animation.client.Animation in project rstudio by rstudio.

the class DocTabLayoutPanel method ensureSelectedTabIsVisible.

public void ensureSelectedTabIsVisible(boolean animate) {
    if (currentAnimation_ != null) {
        currentAnimation_.cancel();
        currentAnimation_ = null;
    }
    Element selectedTab = (Element) DomUtils.findNode(getElement(), true, false, new NodePredicate() {

        public boolean test(Node n) {
            if (n.getNodeType() != Node.ELEMENT_NODE)
                return false;
            return ((Element) n).getClassName().contains("gwt-TabLayoutPanelTab-selected");
        }
    });
    if (selectedTab == null) {
        return;
    }
    selectedTab = selectedTab.getFirstChildElement().getFirstChildElement();
    Element tabBar = getTabBarElement();
    if (!isVisible() || !isAttached() || tabBar.getOffsetWidth() == 0)
        // not yet loaded
        return;
    final Element tabBarParent = tabBar.getParentElement();
    final int start = tabBarParent.getScrollLeft();
    int end = DomUtils.ensureVisibleHoriz(tabBarParent, selectedTab, padding_, padding_ + rightMargin_, true);
    // When tabs are closed, the overall width shrinks, and this can lead
    // to cases where there's too much empty space on the screen
    Node lastTab = getLastChildElement(tabBar);
    if (lastTab == null || lastTab.getNodeType() != Node.ELEMENT_NODE)
        return;
    int edge = DomUtils.getRelativePosition(tabBarParent, Element.as(lastTab)).x + Element.as(lastTab).getOffsetWidth();
    end = Math.min(end, Math.max(0, edge - (tabBarParent.getOffsetWidth() - rightMargin_)));
    if (edge <= tabBarParent.getOffsetWidth() - rightMargin_)
        end = 0;
    if (start != end) {
        if (!animate) {
            tabBarParent.setScrollLeft(end);
        } else {
            final int finalEnd = end;
            currentAnimation_ = new Animation() {

                @Override
                protected void onUpdate(double progress) {
                    double delta = (finalEnd - start) * progress;
                    tabBarParent.setScrollLeft((int) (start + delta));
                }

                @Override
                protected void onComplete() {
                    if (this == currentAnimation_) {
                        tabBarParent.setScrollLeft(finalEnd);
                        currentAnimation_ = null;
                    }
                }
            };
            currentAnimation_.run(Math.max(200, Math.min(1500, Math.abs(end - start) * 2)));
        }
    }
}
Also used : Element(com.google.gwt.dom.client.Element) Node(com.google.gwt.dom.client.Node) Animation(com.google.gwt.animation.client.Animation) Point(org.rstudio.core.client.Point) NodePredicate(org.rstudio.core.client.dom.DomUtils.NodePredicate)

Aggregations

Animation (com.google.gwt.animation.client.Animation)11 Element (com.google.gwt.dom.client.Element)4 Timer (com.google.gwt.user.client.Timer)2 Point (org.rstudio.core.client.Point)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 Node (com.google.gwt.dom.client.Node)1 Style (com.google.gwt.dom.client.Style)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 Element (com.google.gwt.user.client.Element)1 SplitterResizedEvent (com.google.gwt.user.client.ui.SplitterResizedEvent)1 AfterInitialization (org.jboss.errai.ioc.client.api.AfterInitialization)1 KeyboardShortcut (org.rstudio.core.client.command.KeyboardShortcut)1 NodePredicate (org.rstudio.core.client.dom.DomUtils.NodePredicate)1 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)1 RSConnectPublishButton (org.rstudio.studio.client.rsconnect.ui.RSConnectPublishButton)1 EditingTargetToolbar (org.rstudio.studio.client.workbench.views.source.editors.EditingTargetToolbar)1