21
21
import org .dominokit .domino .ui .datatable .DataTable ;
22
22
import org .dominokit .domino .ui .datatable .events .BodyScrollEvent ;
23
23
import org .dominokit .domino .ui .datatable .plugins .DataTablePlugin ;
24
+ import org .dominokit .domino .ui .datatable .plugins .HasPluginConfig ;
24
25
25
26
/**
26
27
* A plugin for handling body scroll events in a DataTable.
27
28
*
28
29
* @param <T> The type of data in the DataTable.
29
30
*/
30
- public class BodyScrollPlugin <T > implements DataTablePlugin <T > {
31
+ public class BodyScrollPlugin <T >
32
+ implements DataTablePlugin <T >, HasPluginConfig <T , BodyScrollPlugin <T >, BodyScrollPluginConfig > {
33
+
34
+ private BodyScrollPluginConfig config = new BodyScrollPluginConfig (0 );
31
35
32
36
/**
33
37
* Initializes the plugin and adds scroll event listeners to the DataTable's body.
@@ -49,12 +53,30 @@ public void onBodyAdded(DataTable<T> dataTable) {
49
53
int clientHeight = new Double (scrollElement .clientHeight ).intValue ();
50
54
51
55
if (JsMath .abs (offsetHeight ) + JsMath .abs (scrollTop )
52
- == new Double (scrollHeight + (offsetHeight - clientHeight )).intValue ()) {
56
+ >= new Double (scrollHeight + (offsetHeight - clientHeight )).intValue ()
57
+ - config .getOffset ()) {
53
58
dataTable .fireTableEvent (new BodyScrollEvent (ScrollPosition .BOTTOM ));
54
59
}
55
60
});
56
61
}
57
62
63
+ /**
64
+ * Sets up the plugin configuration.
65
+ *
66
+ * @param config The plugin configuration.
67
+ */
68
+ @ Override
69
+ public BodyScrollPlugin <T > setConfig (BodyScrollPluginConfig config ) {
70
+ this .config = config ;
71
+ return this ;
72
+ }
73
+
74
+ /** @return the plugin configuration */
75
+ @ Override
76
+ public BodyScrollPluginConfig getConfig () {
77
+ return this .config ;
78
+ }
79
+
58
80
/** An enum representing the scroll position in the DataTable's body. */
59
81
public enum ScrollPosition {
60
82
/** Represents the top scroll position. */
0 commit comments