
gwt.material.design.addins.client.waterfall.MaterialWaterfall Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gwt-material-addins Show documentation
Show all versions of gwt-material-addins Show documentation
Extra Components of GWT Material Framework
package gwt.material.design.addins.client.waterfall;
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 GwtMaterialDesign
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import com.google.gwt.dom.client.Document;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.addins.client.MaterialAddins;
import gwt.material.design.client.MaterialDesignBase;
import gwt.material.design.client.base.MaterialWidget;
//@formatter:off
/**
* Material Waterfall - Act like a collapsible header below the nav bar component when scrolling up / down to provide delightful transition of components.
*
* XML Namespace Declaration
*
* {@code
* xmlns:ma='urn:import:gwt.material.design.addins.client'
* }
*
*
* UiBinder Usage:
*
* {@code
*
*
*
*
*
*
*
*
*
* @see Material Waterfall
* @author kevzlou7979
*/
//@formatter:on
public class MaterialWaterfall extends MaterialWidget {
static {
if(MaterialAddins.isDebug()) {
MaterialDesignBase.injectDebugJs(MaterialWaterfallDebugClientBundle.INSTANCE.waterfallJsDebug());
MaterialDesignBase.injectCss(MaterialWaterfallDebugClientBundle.INSTANCE.waterfallCssDebug());
} else {
MaterialDesignBase.injectJs(MaterialWaterfallClientBundle.INSTANCE.waterfallJs());
MaterialDesignBase.injectCss(MaterialWaterfallClientBundle.INSTANCE.waterfallCss());
}
}
private Runnable openCallback;
private Runnable closeCallback;
private double offset;
public MaterialWaterfall() {
super(Document.get().createDivElement(), "waterfall");
setShadow(1);
}
@Override
protected void onLoad() {
super.onLoad();
if(openCallback == null && closeCallback == null) {
openCallback = new Runnable() {
@Override
public void run() {
for(Widget w : getChildren()){
w.getElement().getStyle().setOpacity(1);
}
}
};
closeCallback = new Runnable() {
@Override
public void run() {
for(Widget w : getChildren()){
w.getElement().getStyle().setOpacity(0);
}
}
};
}
if(offset == 0){
offset = getOffsetHeight();
}
initWaterfall(getElement().getOffsetHeight(), openCallback, closeCallback, offset);
}
public void setCallbacks(Runnable openCallback, Runnable closeCallback) {
this.openCallback = openCallback;
this.closeCallback = closeCallback;
}
private native void initWaterfall(double height, Runnable openCallback, Runnable closeCallback, double offset) /*-{
$wnd.jQuery(document).ready(function() {
var openCallbackFn = $entry(function() {
[email protected]::run()();
});
var closeCallbackFn = $entry(function() {
[email protected]::run()();
});
$wnd.initWaterfall(height, openCallbackFn, closeCallbackFn, offset);
});
}-*/;
public double getOffset() {
return offset;
}
public void setOffset(double offset) {
this.offset = offset;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy