Skip to content

Commit

Permalink
* dtable: support to set elements for responsive.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Oct 10, 2023
1 parent a1653b4 commit faedb22
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions lib/dtable/src/components/dtable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,18 @@ export class DTable extends Component<DTableOptions, DTableState> {
this.on('mouseleave', this.#handleMouseleave as DTableEventListener);
}

if (options.responsive) {
if (typeof ResizeObserver !== 'undefined') {
const {parent} = this;
if (parent) {
const rob = new ResizeObserver(this.updateLayout);
rob.observe(parent);
this.#rob = rob;
const {responsive} = options;
if (responsive) {
if (typeof ResizeObserver !== 'undefined' && responsive !== 'window') {
const rob = new ResizeObserver(this.updateLayout);
this.#rob = rob;
if (typeof responsive === 'string' && responsive !== 'parent') {
$(responsive).each((_, element) => rob.observe(element));
} else {
const {parent} = this;
if (parent) {
rob.observe(parent);
}
}
} else {
this.on('window_resize', this.updateLayout);
Expand Down
2 changes: 1 addition & 1 deletion lib/dtable/src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface DTableLayoutOptions {
footer?: boolean | CustomRenderResultList<[layout: DTableLayout], DTable> | ((this: DTable, layout: DTableLayout) => CustomRenderResultList<[layout: DTableLayout], DTable>);
headerHeight: number;
footerHeight: number;
responsive: boolean;
responsive: boolean | string;
scrollbarHover: boolean;
scrollbarSize?: number;
horzScrollbarPos?: 'inside' | 'outside';
Expand Down

0 comments on commit faedb22

Please sign in to comment.