Skip to content

Commit

Permalink
Fixed #4866 - StyleClass: deprecate enterClass/leaveClass use enterFr…
Browse files Browse the repository at this point in the history
…omClass/leaveFromClass
  • Loading branch information
tugcekucukoglu committed Nov 22, 2023
1 parent cf1ee45 commit 5088314
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/lib/styleclass/StyleClass.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ export interface StyleClassOptions {
selector?: '@next' | '@prev' | '@parent' | '@grandparent' | string | undefined;
/**
* Style class to add when item begins to get displayed.
* @deprecated since v3.41.0. Use 'enterFromClass' option instead.
*/
enterClass?: string | undefined;
/**
* Style class to add when item begins to get displayed.
*/
enterFromClass?: string | undefined;
/**
* Style class to add during enter animation.
*/
Expand All @@ -33,8 +38,13 @@ export interface StyleClassOptions {
enterToClass?: string | undefined;
/**
* Style class to add when item begins to get hidden.
* @deprecated since v3.41.0. Use 'leaveFromClass' option instead.
*/
leaveClass?: string | undefined;
/**
* Style class to add when item begins to get hidden.
*/
leaveFromClass?: string | undefined;
/**
* Style class to add during leave animation.
*/
Expand Down
20 changes: 20 additions & 0 deletions components/lib/styleclass/StyleClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@ const StyleClass = BaseStyleClass.extend('styleclass', {

DomHandler.addClass(target, binding.value.enterActiveClass);

// enterClass will be deprecated, use enterFromClass
if (binding.value.enterClass) {
DomHandler.removeClass(target, binding.value.enterClass);
}

if (binding.value.enterFromClass) {
DomHandler.removeClass(target, binding.value.enterFromClass);
}

target.$p_styleclass_enterlistener = () => {
DomHandler.removeClass(target, binding.value.enterActiveClass);

Expand All @@ -74,10 +79,15 @@ const StyleClass = BaseStyleClass.extend('styleclass', {
target.addEventListener('animationend', target.$p_styleclass_enterlistener);
}
} else {
// enterClass will be deprecated, use enterFromClass
if (binding.value.enterClass) {
DomHandler.removeClass(target, binding.value.enterClass);
}

if (binding.value.enterFromClass) {
DomHandler.removeClass(target, binding.value.enterFromClass);
}

if (binding.value.enterToClass) {
DomHandler.addClass(target, binding.value.enterToClass);
}
Expand All @@ -93,10 +103,15 @@ const StyleClass = BaseStyleClass.extend('styleclass', {
target.$_pstyleclass_animating = true;
DomHandler.addClass(target, binding.value.leaveActiveClass);

// leaveClass will be deprecated, use leaveFromClass
if (binding.value.leaveClass) {
DomHandler.removeClass(target, binding.value.leaveClass);
}

if (binding.value.leaveFromClass) {
DomHandler.removeClass(target, binding.value.leaveFromClass);
}

target.$p_styleclass_leavelistener = () => {
DomHandler.removeClass(target, binding.value.leaveActiveClass);

Expand All @@ -111,10 +126,15 @@ const StyleClass = BaseStyleClass.extend('styleclass', {
target.addEventListener('animationend', target.$p_styleclass_leavelistener);
}
} else {
// leaveClass will be deprecated, use leaveFromClass
if (binding.value.leaveClass) {
DomHandler.removeClass(target, binding.value.leaveClass);
}

if (binding.value.leaveFromClass) {
DomHandler.removeClass(target, binding.value.leaveFromClass);
}

if (binding.value.leaveToClass) {
DomHandler.addClass(target, binding.value.leaveToClass);
}
Expand Down

0 comments on commit 5088314

Please sign in to comment.