Skip to content

Commit

Permalink
Migrate visibility change event to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
Rochmar Nicolas (DevExpress) committed Jul 16, 2024
1 parent f0e51ff commit 943fba1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
36 changes: 21 additions & 15 deletions packages/devextreme/js/__internal/events/m_visibility_change.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import $ from '../core/renderer';
import eventsEngine from './core/events_engine';
import $ from '@js/core/renderer';
import eventsEngine from '@js/events/core/events_engine';

const triggerVisibilityChangeEvent = function(eventName) {
const VISIBILITY_CHANGE_SELECTOR = '.dx-visibility-change-handler';
const triggerVisibilityChangeEvent = function (eventName) {
const VISIBILITY_CHANGE_SELECTOR = '.dx-visibility-change-handler';

return function(element) {
const $element = $(element || 'body');
return function (element) {
const $element = $(element || 'body');

const changeHandlers = $element.filter(VISIBILITY_CHANGE_SELECTOR).
add($element.find(VISIBILITY_CHANGE_SELECTOR));
const changeHandlers = $element.filter(VISIBILITY_CHANGE_SELECTOR)
// @ts-expect-error
.add($element.find(VISIBILITY_CHANGE_SELECTOR));

for(let i = 0; i < changeHandlers.length; i++) {
eventsEngine.triggerHandler(changeHandlers[i], eventName);
}
};
for (let i = 0; i < changeHandlers.length; i++) {
eventsEngine.triggerHandler(changeHandlers[i], eventName);
}
};
};

const triggerShownEvent = triggerVisibilityChangeEvent('dxshown');
const triggerHidingEvent = triggerVisibilityChangeEvent('dxhiding');
const triggerResizeEvent = triggerVisibilityChangeEvent('dxresize');

export const triggerShownEvent = triggerVisibilityChangeEvent('dxshown');
export const triggerHidingEvent = triggerVisibilityChangeEvent('dxhiding');
export const triggerResizeEvent = triggerVisibilityChangeEvent('dxresize');
export {
triggerHidingEvent,
triggerResizeEvent,
triggerShownEvent,
};
5 changes: 5 additions & 0 deletions packages/devextreme/js/events/visibility_change.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export {
triggerHidingEvent,
triggerShownEvent,
triggerResizeEvent
} from '../__internal/events/m_visibility_change';

0 comments on commit 943fba1

Please sign in to comment.