com.google.gwt.animation.client.AnimationScheduler Java Examples

The following examples show how to use com.google.gwt.animation.client.AnimationScheduler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GanttWidget.java    From gantt with Apache License 2.0 6 votes vote down vote up
@Override
public void onScroll(ScrollEvent event) {
    final Element element = event.getNativeEvent().getEventTarget().cast();
    if (element != container) {
        return;
    }
    AnimationScheduler.get().requestAnimationFrame(new AnimationCallback() {

        @Override
        public void execute(double timestamp) {
            int sl = container.getScrollLeft();
            int st = container.getScrollTop();
            if (sl != previousContainerScrollLeft) {
                timeline.setScrollLeft(sl);
                previousContainerScrollLeft = sl;
            }
            if (st != previousContainerScrollTop) {
                previousContainerScrollTop = st;
            }
        }
    });
}
 
Example #2
Source File: GanttConnector.java    From gantt with Apache License 2.0 6 votes vote down vote up
@Override
public void onScroll(ScrollEvent event) {
    if (delegatingVerticalScroll) {
        // if other component is scrolling, don't allow this scroll
        // event
        return;
    }
    AnimationScheduler.get().requestAnimationFrame(new AnimationCallback() {

        @Override
        public void execute(double timestamp) {
            ganttScrollDelay.cancel();
            ganttDelegatingVerticalScroll = true;
            int scrollTop = getWidget().getScrollContainer().getScrollTop();
            try {
                if (delegateScrollGridTarget != null) {
                    delegateScrollGridTarget.setScrollTop(scrollTop);
                }

            } finally {
                ganttScrollDelay.schedule(20);
            }
        }
    });
}
 
Example #3
Source File: GamepadSupport.java    From gdx-controllerutils with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(double timestamp) {
    if (ticking) {
        GamepadSupport.pollGamepads();
        GamepadSupport.pollGamepadsStatus();
        AnimationScheduler.get().requestAnimationFrame(this);
    }
}
 
Example #4
Source File: VComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 5 votes vote down vote up
/**
 * Make the popup follow the position of the ComboBoxMultiselect when
 * the page is scrolled.
 */
private void updatePopupPositionOnScroll() {
	if (!this.scrollPending) {
		AnimationScheduler.get()
			.requestAnimationFrame(timestamp -> {
				if (isShowing()) {
					this.leftPosition = getDesiredLeftPosition();
					this.topPosition = getDesiredTopPosition();
					setPopupPosition(this.leftPosition, this.topPosition);
				}
				this.scrollPending = false;
			});
		this.scrollPending = true;
	}
}
 
Example #5
Source File: VComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 5 votes vote down vote up
/**
 * Make the popup follow the position of the ComboBoxMultiselect when
 * the page is scrolled.
 */
private void updatePopupPositionOnScroll() {
	if (!this.scrollPending) {
		AnimationScheduler.get()
			.requestAnimationFrame(timestamp -> {
				if (isShowing()) {
					this.leftPosition = getDesiredLeftPosition();
					this.topPosition = getDesiredTopPosition();
					setPopupPosition(this.leftPosition, this.topPosition);
				}
				this.scrollPending = false;
			});
		this.scrollPending = true;
	}
}
 
Example #6
Source File: WrappingGridConnector.java    From GridExtensionPack with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void extend(ServerConnector target) {
	grid = (Grid<?>) ((ComponentConnector) target).getWidget();

	wrappingEnabled = false;
	WrappingClientRPC rpc = new WrappingClientRPC() {
		@Override
		public void setWrapping(boolean enable, int defaultRowHeight) {
			if (wrappingEnabled != enable) {
				wrappingEnabled = enable;
				DEFAULT_HEIGHT = defaultRowHeight;
				if (enable) {
					// Figure out default header height
					applyStyle.execute(0);
				} else {
					disableWrapping();
				}
			}
		}
	};

	registerRpc(WrappingClientRPC.class, rpc);

	resizeHandler = grid.addColumnResizeHandler(new ColumnResizeHandler() {
		@Override
		public void onColumnResize(ColumnResizeEvent event) {
			Scheduler.get().scheduleFinally(new Scheduler.ScheduledCommand() {
				@Override
				public void execute() {
					AnimationScheduler.get().requestAnimationFrame(applyStyle);						
				}
			});
		}
	});
}
 
Example #7
Source File: WrappingGridConnector.java    From GridExtensionPack with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(double timestamp) {
	if (!wrappingEnabled) {
		return;
	}

	for (Element e : getGridParts("th")) {
		addWrappingRules(e);
	}

	double[] heights = measureRowHeights();
	double startY = setHeaderHeight(heights);
	setBodyStartY(startY);
	AnimationScheduler.get().requestAnimationFrame(applyScrollBarHeight);						
}
 
Example #8
Source File: GanttConnector.java    From gantt with Apache License 2.0 5 votes vote down vote up
@Override
public void onScroll(ScrollEvent event) {
    if (ganttDelegatingVerticalScroll) {
        // if gantt is scrolling, don't allow this scroll event
        return;
    }
    AnimationScheduler.get().requestAnimationFrame(new AnimationCallback() {

        @Override
        public void execute(double timestamp) {
            onDelegateScroll();
        }
    });
}
 
Example #9
Source File: GanttConnector.java    From gantt with Apache License 2.0 5 votes vote down vote up
@Override
public void onScroll(com.vaadin.client.widget.grid.events.ScrollEvent event) {
    if (ganttDelegatingVerticalScroll) {
        // if gantt is scrolling, don't allow this scroll event
        return;
    }
    AnimationScheduler.get().requestAnimationFrame(new AnimationCallback() {

        @Override
        public void execute(double timestamp) {
            onDelegateScroll();
        }
    });
}
 
Example #10
Source File: GamepadSupport.java    From gdx-controllerutils with Apache License 2.0 4 votes vote down vote up
public void start() {
    if (!ticking) {
        ticking = true;
        AnimationScheduler.get().requestAnimationFrame(this);
    }
}