-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate visibility change event to TS
- Loading branch information
Rochmar Nicolas (DevExpress)
committed
Jul 16, 2024
1 parent
f0e51ff
commit 943fba1
Showing
2 changed files
with
26 additions
and
15 deletions.
There are no files selected for viewing
36 changes: 21 additions & 15 deletions
36
packages/devextreme/js/__internal/events/m_visibility_change.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export { | ||
triggerHidingEvent, | ||
triggerShownEvent, | ||
triggerResizeEvent | ||
} from '../__internal/events/m_visibility_change'; |