Skip to content

Commit 1701d8b

Browse files
authored
Merge pull request #251 from gkresic/window-dnd
MaterialWindow DND customizations
2 parents 470dde0 + 78e3a6c commit 1701d8b

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/main/java/gwt/material/design/addins/client/window/MaterialWindow.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,27 @@ protected void build() {
170170
setTop(100);
171171

172172
// Add a draggable header
173-
dnd = MaterialDnd.draggable(this, JsDragOptions.create(
174-
new Restriction("body", true, 0, 0, 1.2, 1)));
175-
dnd.ignoreFrom(".content, .window-action");
173+
dnd = buildDnd();
174+
}
175+
176+
/**
177+
* Override to provide custom options for window drag'n'drop
178+
*/
179+
protected JsDragOptions buildDragOptions() {
180+
return JsDragOptions.create(new Restriction("body", true, 0, 0, 1.2, 1));
176181
}
177182

183+
/**
184+
* Override to provide custom {@link MaterialDnd} instance. Default implementation will construct {@link MaterialDnd}
185+
* using options provided by {@link {@link #buildDragOptions()} and will ignore drag events from content portion of
186+
* the window ({@link AddinsCssName#CONTENT}) as well from action buttons (close, maximize and other {@link AddinsCssName#WINDOW_ACTION}.
187+
*/
188+
protected MaterialDnd buildDnd() {
189+
MaterialDnd dnd = MaterialDnd.draggable(this, buildDragOptions());
190+
dnd.ignoreFrom(".content, .window-action");
191+
return dnd;
192+
}
193+
178194
protected void onClose() {
179195

180196
}

0 commit comments

Comments
 (0)