Skip to content

Commit

Permalink
Core: fix viewport IIFE after lint changes and add it to lint ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanblinov2k17 committed Oct 10, 2024
1 parent 36683b9 commit 491aa09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/devextreme/js/__internal/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
plugins: [
'simple-import-sort',
],
ignorePatterns: ['core/utils/m_view_port.ts'],
overrides: [
// General TS rules.
{
Expand Down
29 changes: 15 additions & 14 deletions packages/devextreme/js/__internal/core/utils/m_view_port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@ const ready = readyCallbacks.add;
const changeCallback = callbacks();
let $originalViewPort = $();

const value = (function (...args) {
const value: any = (function () {
let $current;

return function (element?) {
if (!args.length) {
return $current;
}

const $element = $(element);
$originalViewPort = $element;
const isNewViewportFound = !!$element.length;
const prevViewPort = value();
$current = isNewViewportFound ? $element : $('body');
changeCallback.fire(isNewViewportFound ? value() : $(), prevViewPort);
return function(element) {
if(!arguments.length) {
return $current;
}

const $element = $(element);
$originalViewPort = $element;
const isNewViewportFound = !!$element.length;
const prevViewPort = value();
$current = isNewViewportFound ? $element : $('body');
changeCallback.fire(isNewViewportFound ? value() : $(), prevViewPort);
};
}());
})();

ready(() => {
ready(function() {
value('.dx-viewport');
});


export {
changeCallback,
value,
Expand Down

0 comments on commit 491aa09

Please sign in to comment.