com.vaadin.client.widget.escalator.
Class ScrollbarBundle
- java.lang.Object
-
- com.vaadin.client.widget.escalator.ScrollbarBundle
-
All Implemented Interfaces:
Direct Known Subclasses:
ScrollbarBundle.HorizontalScrollbarBundle
,ScrollbarBundle.VerticalScrollbarBundle
public abstract class ScrollbarBundle extends Object implements DeferredWorker
An element-like bundle representing a configurable and visual scrollbar in one axis.
Since:
7.4
Author:
Vaadin Ltd
See Also:
ScrollbarBundle.VerticalScrollbarBundle
,ScrollbarBundle.HorizontalScrollbarBundle
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ScrollbarBundle.Direction
The orientation of the scrollbar.
static class
ScrollbarBundle.HorizontalScrollbarBundle
A representation of a single horizontal scrollbar.
static class
ScrollbarBundle.VerticalScrollbarBundle
A representation of a single vertical scrollbar.
static class
ScrollbarBundle.VisibilityChangeEvent
Event for scrollbar visibility changes.
static interface
ScrollbarBundle.VisibilityHandler
A means to listen to when the scrollbar handle in a
ScrollbarBundle
either appears or is removed.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
isInvisibleScrollbar
Is the scrollbar "invisible" (thickness set to 0).
protected com.google.gwt.dom.client.Element
root
Root element for the scrollbar-composition.
protected com.google.gwt.dom.client.Element
scrollSizeElement
Scroll size element.
-
Method Summary
All Methods Modifier and Type Method Description com.google.gwt.event.shared.HandlerRegistration
addScrollHandler(ScrollHandler handler)
Adds a scroll handler to the scrollbar bundle.
com.google.gwt.event.shared.HandlerRegistration
addVisibilityHandler(ScrollbarBundle.VisibilityHandler handler)
Adds handler for the scrollbar handle visibility.
protected void
forceScrollbar(boolean enable)
Force the scrollbar to be visible with CSS.
abstract ScrollbarBundle.Direction
getDirection()
Returns the scroll direction of this scrollbar bundle.
com.google.gwt.dom.client.Element
getElement()
Gets the root element of this scrollbar-composition.
protected com.google.gwt.event.shared.HandlerManager
getHandlerManager()
Returns the handler manager for this scrollbar bundle.
double
getOffsetSize()
Gets the length of the scrollbar.
double
getScrollbarThickness()
Gets the scrollbar's thickness.
double
getScrollPos()
Gets the scroll position of the scrollbar in the axis the scrollbar is representing.
double
getScrollSize()
Gets the amount of pixels the scrollbar needs to be able to scroll through.
protected abstract void
internalForceScrollbar(boolean enable)
Sets the overflow-x (for horizontal) or overflow-y (for vertical) property to
"scroll"
if enabled, or clears the property if disabled.abstract String
internalGetOffsetSize()
Returns the width (for horizontal) or height (for vertical) css property for the root element.
protected abstract String
internalGetScrollbarThickness()
Gets the scrollbar's thickness as defined in the DOM.
protected abstract int
internalGetScrollPos()
Retrieves the element's scroll position (scrollTop or scrollLeft).
protected abstract String
internalGetScrollSize()
Returns the width (for horizontal) or height (for vertical) css property for the scroll size element.
protected abstract void
internalSetOffsetSize(double px)
Modifies
root's
dimensions in the axis the scrollbar is representing.protected abstract void
internalSetScrollbarThickness(double px)
Modifies
scrollSizeElement's
dimensions in the opposite axis to what the scrollbar is representing.protected abstract void
internalSetScrollPos(int px)
Modifies the element's scroll position (scrollTop or scrollLeft).
protected abstract void
internalSetScrollSize(double px)
Modifies
scrollSizeElement's
dimensions in such a way that the scrollbar is able to scroll a certain number of pixels in the axis it is representing.boolean
isLocked()
Checks whether the scrollbar bundle is locked or not.
boolean
isWorkPending()
Checks whether there are operations pending for this widget or connector that must be executed before reaching a steady state.
void
onLoad()
Should be called whenever this bundle is attached to the DOM (typically, from the onLoad of the containing widget).
void
recalculateMaxScrollPos()
Calculates and sets maximum scroll position based on the current scroll size and the scrollbar's length.
void
setLocked(boolean isLocked)
Locks or unlocks the scrollbar bundle.
void
setOffsetSize(double px)
Sets the length of the scrollbar.
void
setOffsetSizeAndScrollSize(double offsetPx, double scrollPx)
Sets the length of the scrollbar and the amount of pixels the scrollbar needs to be able to scroll through.
void
setScrollbarThickness(double px)
Sets the scrollbar's thickness.
void
setScrollPos(double px)
Sets the scroll position of the scrollbar in the axis the scrollbar is representing.
void
setScrollPosByDelta(double delta)
Modifies the scroll position of this scrollbar by a number of pixels.
void
setScrollSize(double px)
Sets the amount of pixels the scrollbar needs to be able to scroll through.
void
setStylePrimaryName(String primaryStyleName)
Sets the primary style name.
boolean
showsScrollHandle()
Checks whether the scrollbar's handle is visible.
-
-
-
Field Detail
-
root
protected final com.google.gwt.dom.client.Element root
Root element for the scrollbar-composition.
-
scrollSizeElement
protected final com.google.gwt.dom.client.Element scrollSizeElement
Scroll size element. The size of this element determines the number of pixels the scrollbar is able to scroll through
-
isInvisibleScrollbar
protected boolean isInvisibleScrollbar
Is the scrollbar "invisible" (thickness set to 0).
-
-
Method Detail
-
internalGetScrollSize
protected abstract String internalGetScrollSize()
Returns the width (for horizontal) or height (for vertical) css property for the scroll size element.
Returns:
the relevant size property based on orientation
-
setStylePrimaryName
public void setStylePrimaryName(String primaryStyleName)
Sets the primary style name.
Parameters:
primaryStyleName
- The primary style name to use
-
getElement
public final com.google.gwt.dom.client.Element getElement()
Gets the root element of this scrollbar-composition.
Returns:
the root element
-
setScrollPosByDelta
public final void setScrollPosByDelta(double delta)
Modifies the scroll position of this scrollbar by a number of pixels.
Note: Even though
double
values are used, they are currently only used as integers as largeint
(or small but fastlong
). This means, all values are truncated to zero decimal places.Parameters:
delta
- the delta in pixels to change the scroll position by
-
internalSetOffsetSize
protected abstract void internalSetOffsetSize(double px)
Modifies
root's
dimensions in the axis the scrollbar is representing.Parameters:
px
- the new size ofroot
in the dimension this scrollbar is representing
-
setOffsetSize
public final void setOffsetSize(double px)
Sets the length of the scrollbar.
Parameters:
px
- the length of the scrollbar in pixelsSee Also:
-
setOffsetSizeAndScrollSize
public final void setOffsetSizeAndScrollSize(double offsetPx, double scrollPx)
Sets the length of the scrollbar and the amount of pixels the scrollbar needs to be able to scroll through.
Parameters:
offsetPx
- the length of the scrollbar in pixelsscrollPx
- the number of pixels the scrollbar should be able to scroll through
-
forceScrollbar
protected void forceScrollbar(boolean enable)
Force the scrollbar to be visible with CSS. In practice, this means to set either
overflow-x
oroverflow-y
to "scroll
" in the scrollbar's direction.This method is an IE8 workaround, since it doesn't always show scrollbars with
overflow: auto
enabled.Firefox on the other hand loses pending scroll events when the scrollbar is hidden, so the event must be fired manually.
When IE8 support is dropped, this should really be simplified.
Parameters:
enable
-true
if the scrollbar should be forced to be visible,false
otherwise.
-
internalForceScrollbar
protected abstract void internalForceScrollbar(boolean enable)
Sets the overflow-x (for horizontal) or overflow-y (for vertical) property to
"scroll"
if enabled, or clears the property if disabled.Parameters:
enable
-true
if the overflow property should be set,false
otherwise.
-
getOffsetSize
public double getOffsetSize()
Gets the length of the scrollbar.
Returns:
the length of the scrollbar in pixels
-
internalGetOffsetSize
public abstract String internalGetOffsetSize()
Returns the width (for horizontal) or height (for vertical) css property for the root element.
Returns:
the relevant size property based on orientation
-
setScrollPos
public final void setScrollPos(double px)
Sets the scroll position of the scrollbar in the axis the scrollbar is representing.
Note: Even though
double
values are used, they are currently only used as integers as largeint
(or small but fastlong
). This means, all values are truncated to zero decimal places.Parameters:
px
- the new scroll position in pixels
-
onLoad
public void onLoad()
Should be called whenever this bundle is attached to the DOM (typically, from the onLoad of the containing widget). Used to ensure the DOM scroll position is maintained when detaching and reattaching the bundle.
Since:
7.4.1
-
internalSetScrollPos
protected abstract void internalSetScrollPos(int px)
Modifies the element's scroll position (scrollTop or scrollLeft).
Note: The parameter here is a type of integer (instead of a double) by design. The browsers internally convert all double values into an integer value. To make this fact explicit, this API has chosen to force integers already at this level.
Parameters:
px
- integer pixel value to scroll to
-
getScrollPos
public final double getScrollPos()
Gets the scroll position of the scrollbar in the axis the scrollbar is representing.
Returns:
the new scroll position in pixels
-
internalGetScrollPos
protected abstract int internalGetScrollPos()
Retrieves the element's scroll position (scrollTop or scrollLeft).
Note: The parameter here is a type of integer (instead of a double) by design. The browsers internally convert all double values into an integer value. To make this fact explicit, this API has chosen to force integers already at this level.
Returns:
integer pixel value of the scroll position
-
internalSetScrollSize
protected abstract void internalSetScrollSize(double px)
Modifies
scrollSizeElement's
dimensions in such a way that the scrollbar is able to scroll a certain number of pixels in the axis it is representing.Parameters:
px
- the new size ofscrollSizeElement
in the dimension this scrollbar is representing
-
setScrollSize
public final void setScrollSize(double px)
Sets the amount of pixels the scrollbar needs to be able to scroll through.
Parameters:
px
- the number of pixels the scrollbar should be able to scroll throughSee Also:
-
getScrollSize
public double getScrollSize()
Gets the amount of pixels the scrollbar needs to be able to scroll through.
Returns:
the number of pixels the scrollbar should be able to scroll through
-
internalSetScrollbarThickness
protected abstract void internalSetScrollbarThickness(double px)
Modifies
scrollSizeElement's
dimensions in the opposite axis to what the scrollbar is representing.Parameters:
px
- the dimension thatscrollSizeElement
should take in the opposite axis to what the scrollbar is representing
-
setScrollbarThickness
public final void setScrollbarThickness(double px)
Sets the scrollbar's thickness.
If the thickness is set to 0, the scrollbar will be treated as an "invisible" scrollbar. This means, the DOM structure will be given a non-zero size, but
getScrollbarThickness()
will still return the value 0.Parameters:
px
- the scrollbar's thickness in pixels
-
internalGetScrollbarThickness
protected abstract String internalGetScrollbarThickness()
Gets the scrollbar's thickness as defined in the DOM.
Returns:
the scrollbar's thickness as defined in the DOM, in pixels
-
getScrollbarThickness
public final double getScrollbarThickness()
Gets the scrollbar's thickness.
This value will differ from the value in the DOM, if the thickness was set to 0 with
setScrollbarThickness(double)
, as the scrollbar is then treated as "invisible."Returns:
the scrollbar's thickness in pixels
-
showsScrollHandle
public boolean showsScrollHandle()
Checks whether the scrollbar's handle is visible.
In other words, this method checks whether the contents is larger than can visually fit in the element.
Returns:
true
if the scrollbar's handle is visible
-
recalculateMaxScrollPos
public void recalculateMaxScrollPos()
Calculates and sets maximum scroll position based on the current scroll size and the scrollbar's length.
-
getHandlerManager
protected com.google.gwt.event.shared.HandlerManager getHandlerManager()
Returns the handler manager for this scrollbar bundle.
Returns:
the handler manager
-
addVisibilityHandler
public com.google.gwt.event.shared.HandlerRegistration addVisibilityHandler(ScrollbarBundle.VisibilityHandler handler)
Adds handler for the scrollbar handle visibility.
Parameters:
handler
- theScrollbarBundle.VisibilityHandler
to addReturns:
HandlerRegistration
used to remove the handler
-
setLocked
public void setLocked(boolean isLocked)
Locks or unlocks the scrollbar bundle.
A locked scrollbar bundle will refuse to scroll, both programmatically and via user-triggered events.
Parameters:
isLocked
-true
to lock,false
to unlock
-
isLocked
public boolean isLocked()
Checks whether the scrollbar bundle is locked or not.
Returns:
true
if the scrollbar bundle is locked
-
getDirection
public abstract ScrollbarBundle.Direction getDirection()
Returns the scroll direction of this scrollbar bundle.
Returns:
the scroll direction of this scrollbar bundle
-
addScrollHandler
public com.google.gwt.event.shared.HandlerRegistration addScrollHandler(ScrollHandler handler)
Adds a scroll handler to the scrollbar bundle.
Parameters:
handler
- the handler to addReturns:
the registration object for the handler registration
-
isWorkPending
public boolean isWorkPending()
Description copied from interface:
DeferredWorker
Checks whether there are operations pending for this widget or connector that must be executed before reaching a steady state.
Specified by:
isWorkPending
in interfaceDeferredWorker
-
-