Skip to content

Commit db8fcb0

Browse files
committed
make monkey play nice with other monkeys
1 parent 7b048fc commit db8fcb0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/src/nativescript-ngx-shadow/ng-shadow.directive.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class NativeShadowDirective implements OnInit, OnChanges {
3636
private loaded = false;
3737
private initialized = false;
3838
private originalNSFn: any;
39+
private previousNSFn: any;
3940

4041
constructor(private el: ElementRef) {
4142
if(isAndroid) {
@@ -76,6 +77,7 @@ export class NativeShadowDirective implements OnInit, OnChanges {
7677
}
7778
this.applyShadow();
7879
if (isAndroid) {
80+
this.previousNSFn = this.el.nativeElement._redrawNativeBackground; // just to maintain compatibility with other patches
7981
this.el.nativeElement._redrawNativeBackground = this.monkeyPatch;
8082
}
8183
}
@@ -85,7 +87,7 @@ export class NativeShadowDirective implements OnInit, OnChanges {
8587
this.loaded = false;
8688

8789
if (isAndroid) {
88-
this.el.nativeElement._redrawNativeBackground = this.originalNSFn;
90+
this.el.nativeElement._redrawNativeBackground = this.originalNSFn; // always revert to the original method
8991
}
9092
}
9193

@@ -127,7 +129,7 @@ export class NativeShadowDirective implements OnInit, OnChanges {
127129
}
128130

129131
private monkeyPatch = (val) => {
130-
this.originalNSFn.call(this.el.nativeElement, val);
132+
this.previousNSFn.call(this.el.nativeElement, val);
131133
this.applyShadow();
132134
}
133135

0 commit comments

Comments
 (0)