Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove leftover jQuery animations in all toggle methods #1196

Merged
merged 3 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions packages/common/src/core/slickCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,23 +830,6 @@ export class Utils {
}
}

public static slideUp(el: HTMLElement | HTMLElement[], callback: () => void) {
return Utils.slideAnimation(el, 'slideUp', callback);
}

public static slideDown(el: HTMLElement | HTMLElement[], callback: () => void) {
return Utils.slideAnimation(el, 'slideDown', callback);
}

public static slideAnimation(el: HTMLElement | HTMLElement[], slideDirection: 'slideDown' | 'slideUp', callback: () => void) {
if ((window as any).jQuery !== undefined) {
(window as any).jQuery(el)[slideDirection]('fast', callback);
return;
}
(slideDirection === 'slideUp') ? Utils.hide(el) : Utils.show(el);
callback();
}

public static applyDefaults(targetObj: any, srcObj: any) {
for (const key in srcObj) {
if (srcObj.hasOwnProperty(key) && !targetObj.hasOwnProperty(key)) {
Expand Down
47 changes: 16 additions & 31 deletions packages/common/src/core/slickGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3621,72 +3621,57 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
return !Array.isArray(this.data);
}

protected togglePanelVisibility(option: 'showTopPanel' | 'showHeaderRow' | 'showColumnHeader' | 'showFooterRow' | 'showPreHeaderPanel', container: HTMLElement | HTMLElement[], visible?: boolean, animate?: boolean) {
const animated = (animate === false) ? false : true;

protected togglePanelVisibility(option: 'showTopPanel' | 'showHeaderRow' | 'showColumnHeader' | 'showFooterRow' | 'showPreHeaderPanel', container: HTMLElement | HTMLElement[], visible?: boolean) {
if (this._options[option] !== visible) {
this._options[option] = visible as boolean;
if (visible) {
if (animated) {
Utils.slideDown(container, this.resizeCanvas.bind(this));
return;
}
Utils.show(container);
this.resizeCanvas();
} else {
if (animated) {
Utils.slideUp(container, this.resizeCanvas.bind(this));
return;
}
Utils.hide(container);
this.resizeCanvas();
}
}
}

/**
* Set the Top Panel Visibility and optionally enable/disable animation (enabled by default)
* Set the Top Panel Visibility
* @param {Boolean} [visible] - optionally set if top panel is visible or not
* @param {Boolean} [animate] - optionally enable an animation while toggling the panel
*/
setTopPanelVisibility(visible?: boolean, animate?: boolean) {
this.togglePanelVisibility('showTopPanel', this._topPanelScrollers, visible, animate);
setTopPanelVisibility(visible?: boolean) {
this.togglePanelVisibility('showTopPanel', this._topPanelScrollers, visible);
}

/**
* Set the Header Row Visibility and optionally enable/disable animation (enabled by default)
* Set the Header Row Visibility
* @param {Boolean} [visible] - optionally set if header row panel is visible or not
* @param {Boolean} [animate] - optionally enable an animation while toggling the panel
*/
setHeaderRowVisibility(visible?: boolean, animate?: boolean) {
this.togglePanelVisibility('showHeaderRow', this._headerRowScroller, visible, animate);
setHeaderRowVisibility(visible?: boolean) {
this.togglePanelVisibility('showHeaderRow', this._headerRowScroller, visible);
}

/**
* Set the Column Header Visibility and optionally enable/disable animation (enabled by default)
* Set the Column Header Visibility
* @param {Boolean} [visible] - optionally set if column header is visible or not
* @param {Boolean} [animate] - optionally enable an animation while toggling the panel
*/
setColumnHeaderVisibility(visible?: boolean, animate?: boolean) {
this.togglePanelVisibility('showColumnHeader', this._headerScroller, visible, animate);
setColumnHeaderVisibility(visible?: boolean) {
this.togglePanelVisibility('showColumnHeader', this._headerScroller, visible);
}

/**
* Set the Footer Visibility and optionally enable/disable animation (enabled by default)
* Set the Footer Visibility
* @param {Boolean} [visible] - optionally set if footer row panel is visible or not
* @param {Boolean} [animate] - optionally enable an animation while toggling the panel
*/
setFooterRowVisibility(visible?: boolean, animate?: boolean) {
this.togglePanelVisibility('showFooterRow', this._footerRowScroller, visible, animate);
setFooterRowVisibility(visible?: boolean) {
this.togglePanelVisibility('showFooterRow', this._footerRowScroller, visible);
}

/**
* Set the Pre-Header Visibility and optionally enable/disable animation (enabled by default)
* Set the Pre-Header Visibility
* @param {Boolean} [visible] - optionally set if pre-header panel is visible or not
* @param {Boolean} [animate] - optionally enable an animation while toggling the panel
*/
setPreHeaderPanelVisibility(visible?: boolean, animate?: boolean) {
this.togglePanelVisibility('showPreHeaderPanel', [this._preHeaderPanelScroller, this._preHeaderPanelScrollerR], visible, animate);
setPreHeaderPanelVisibility(visible?: boolean) {
this.togglePanelVisibility('showPreHeaderPanel', [this._preHeaderPanelScroller, this._preHeaderPanelScrollerR], visible);
}

/** Get Grid Canvas Node DOM Element */
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/global-grid-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const GlobalGridOptions: Partial<GridOption> = {
},
columnGroupSeparator: ' - ',
columnPicker: {
fadeSpeed: 0,
hideForceFitButton: false,
hideSyncResizeButton: true,
headerColumnValueExtractor: pickerHeaderColumnValueExtractor
Expand Down
3 changes: 0 additions & 3 deletions packages/common/src/interfaces/columnPicker.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ export interface ColumnPickerOption {
/** Defaults to "Force fit columns" which is 1 of the last 2 checkbox title shown at the end of the picker list */
forceFitTitle?: string;

/** Animation fade speed when opening/closing the column picker */
fadeSpeed?: number;

/** Defaults to True, show/hide 1 of the last 2 checkbox at the end of the picker list */
hideForceFitButton?: boolean;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ describe('Slick-Vanilla-Grid-Bundle Component instantiated via Constructor', ()
component.initialization(divContainer, slickEventHandler);
component.showHeaderRow(true);

expect(setHeaderRowSpy).toHaveBeenCalledWith(true, false);
expect(setHeaderRowSpy).toHaveBeenCalledWith(true);
expect(setColumnSpy).toHaveBeenCalledTimes(1);
});

Expand All @@ -1658,7 +1658,7 @@ describe('Slick-Vanilla-Grid-Bundle Component instantiated via Constructor', ()
component.initialization(divContainer, slickEventHandler);
component.showHeaderRow(false);

expect(setHeaderRowSpy).toHaveBeenCalledWith(false, false);
expect(setHeaderRowSpy).toHaveBeenCalledWith(false);
expect(setColumnSpy).not.toHaveBeenCalled();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ export class SlickVanillaGridBundle<TData = any> {
* @param showing
*/
showHeaderRow(showing = true) {
this.slickGrid?.setHeaderRowVisibility(showing, false);
this.slickGrid?.setHeaderRowVisibility(showing);
if (this.slickGrid && showing === true && this._isGridInitialized) {
this.slickGrid.setColumns(this.columnDefinitions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ describe('Vanilla-Force-Grid-Bundle Component instantiated via Constructor', ()
component.initialization(divContainer, slickEventHandler);
component.showHeaderRow(true);

expect(setHeaderRowSpy).toHaveBeenCalledWith(true, false);
expect(setHeaderRowSpy).toHaveBeenCalledWith(true);
expect(setColumnSpy).toHaveBeenCalledTimes(1);
});

Expand All @@ -628,7 +628,7 @@ describe('Vanilla-Force-Grid-Bundle Component instantiated via Constructor', ()
component.initialization(divContainer, slickEventHandler);
component.showHeaderRow(false);

expect(setHeaderRowSpy).toHaveBeenCalledWith(false, false);
expect(setHeaderRowSpy).toHaveBeenCalledWith(false);
expect(setColumnSpy).not.toHaveBeenCalled();
});
});
Expand Down