@skyux/core 5.1.3 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/skyux-core.umd.js +98 -14
- package/bundles/skyux-core.umd.js.map +1 -1
- package/documentation.json +132 -144
- package/esm2015/modules/scrollable-host/scrollable-host.service.js +88 -16
- package/esm2015/modules/viewkeeper/viewkeeper.directive.js +2 -2
- package/fesm2015/skyux-core.js +88 -16
- package/fesm2015/skyux-core.js.map +1 -1
- package/modules/scrollable-host/scrollable-host.service.d.ts +21 -2
- package/package.json +1 -1
@@ -2950,31 +2950,115 @@
|
|
2950
2950
|
}]
|
2951
2951
|
}] });
|
2952
2952
|
|
2953
|
+
function notifySubscribers(subscribers, item) {
|
2954
|
+
var e_1, _a;
|
2955
|
+
try {
|
2956
|
+
for (var subscribers_1 = __values(subscribers), subscribers_1_1 = subscribers_1.next(); !subscribers_1_1.done; subscribers_1_1 = subscribers_1.next()) {
|
2957
|
+
var subscriber = subscribers_1_1.value;
|
2958
|
+
subscriber.next(item);
|
2959
|
+
}
|
2960
|
+
}
|
2961
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
2962
|
+
finally {
|
2963
|
+
try {
|
2964
|
+
if (subscribers_1_1 && !subscribers_1_1.done && (_a = subscribers_1.return)) _a.call(subscribers_1);
|
2965
|
+
}
|
2966
|
+
finally { if (e_1) throw e_1.error; }
|
2967
|
+
}
|
2968
|
+
}
|
2953
2969
|
var SkyScrollableHostService = /** @class */ (function () {
|
2954
2970
|
function SkyScrollableHostService(mutationObserverSvc, windowRef) {
|
2955
2971
|
this.mutationObserverSvc = mutationObserverSvc;
|
2956
2972
|
this.windowRef = windowRef;
|
2957
2973
|
}
|
2958
|
-
|
2974
|
+
/**
|
2975
|
+
* Returns the given element's current scrollable host
|
2976
|
+
* @param elementRef The element whose scrollable host is being requested
|
2977
|
+
* @returns The current scrollable host
|
2978
|
+
*/
|
2979
|
+
SkyScrollableHostService.prototype.getScrollableHost = function (elementRef) {
|
2959
2980
|
return this.findScrollableHost(elementRef.nativeElement);
|
2960
2981
|
};
|
2961
|
-
|
2982
|
+
/**
|
2983
|
+
* Returns an observable which emits the given element's current scrollable host
|
2984
|
+
* @param elementRef The element whose scrollable host is being requested
|
2985
|
+
* @param completionObservable An observable which alerts the internal observers that they should complete
|
2986
|
+
* @returns An observable which emits the current scrollable host
|
2987
|
+
* @internal
|
2988
|
+
*/
|
2989
|
+
SkyScrollableHostService.prototype.watchScrollableHost = function (elementRef) {
|
2962
2990
|
var _this = this;
|
2963
|
-
var
|
2964
|
-
var
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
2968
|
-
|
2991
|
+
var subscribers = [];
|
2992
|
+
var mutationObserver;
|
2993
|
+
return new rxjs.Observable(function (subscriber) {
|
2994
|
+
subscribers.push(subscriber);
|
2995
|
+
var scrollableHost = _this.findScrollableHost(elementRef.nativeElement);
|
2996
|
+
if (subscribers.length === 1) {
|
2997
|
+
mutationObserver = _this.mutationObserverSvc.create(function () {
|
2998
|
+
var newScrollableHost = _this.findScrollableHost(elementRef.nativeElement);
|
2999
|
+
if (newScrollableHost !== scrollableHost) {
|
3000
|
+
scrollableHost = newScrollableHost;
|
3001
|
+
_this.observeForScrollableHostChanges(scrollableHost, mutationObserver);
|
3002
|
+
notifySubscribers(subscribers, scrollableHost);
|
3003
|
+
}
|
3004
|
+
});
|
2969
3005
|
_this.observeForScrollableHostChanges(scrollableHost, mutationObserver);
|
2970
|
-
behaviorSubject.next(scrollableHost);
|
2971
3006
|
}
|
3007
|
+
subscriber.next(scrollableHost);
|
3008
|
+
subscriber.add(function () {
|
3009
|
+
var subIndex = subscribers.indexOf(subscriber);
|
3010
|
+
/* sanity check */
|
3011
|
+
/* istanbul ignore else */
|
3012
|
+
if (subIndex >= 0) {
|
3013
|
+
subscribers.splice(subIndex, 1);
|
3014
|
+
}
|
3015
|
+
if (subscribers.length === 0) {
|
3016
|
+
mutationObserver.disconnect();
|
3017
|
+
}
|
3018
|
+
});
|
2972
3019
|
});
|
2973
|
-
|
2974
|
-
|
2975
|
-
|
3020
|
+
};
|
3021
|
+
/**
|
3022
|
+
* Returns an observable which emits whenever the element's scrollable host emits a scroll event. The observable will always emit the scroll events from the elements current scrollable host and will update based on any scrollable host changes. The observable will also emit once whenever the scrollable host changes.
|
3023
|
+
* @param elementRef The element whose scrollable host scroll events are being requested
|
3024
|
+
* @param completionObservable An observable which alerts the internal observers that they should complete
|
3025
|
+
* @returns An observable which emits the scroll events from the given element's scrollable host
|
3026
|
+
*/
|
3027
|
+
SkyScrollableHostService.prototype.watchScrollableHostScrollEvents = function (elementRef) {
|
3028
|
+
var _this = this;
|
3029
|
+
var subscribers = [];
|
3030
|
+
var newScrollableHostObservable = new rxjs.Subject();
|
3031
|
+
var scrollableHostSubscription;
|
3032
|
+
var scrollEventSubscription;
|
3033
|
+
return new rxjs.Observable(function (subscriber) {
|
3034
|
+
subscribers.push(subscriber);
|
3035
|
+
if (subscribers.length === 1) {
|
3036
|
+
scrollableHostSubscription = _this.watchScrollableHost(elementRef)
|
3037
|
+
.subscribe(function (scrollableHost) {
|
3038
|
+
newScrollableHostObservable.next();
|
3039
|
+
newScrollableHostObservable.complete();
|
3040
|
+
newScrollableHostObservable = new rxjs.Subject();
|
3041
|
+
scrollEventSubscription = rxjs.fromEvent(scrollableHost, 'scroll')
|
3042
|
+
.pipe(operators.takeUntil(newScrollableHostObservable))
|
3043
|
+
.subscribe(function () {
|
3044
|
+
notifySubscribers(subscribers);
|
3045
|
+
});
|
3046
|
+
});
|
3047
|
+
}
|
3048
|
+
subscriber.add(function () {
|
3049
|
+
var subIndex = subscribers.indexOf(subscriber);
|
3050
|
+
/* sanity check */
|
3051
|
+
/* istanbul ignore else */
|
3052
|
+
if (subIndex >= 0) {
|
3053
|
+
subscribers.splice(subIndex, 1);
|
3054
|
+
}
|
3055
|
+
if (subscribers.length === 0) {
|
3056
|
+
scrollableHostSubscription.unsubscribe();
|
3057
|
+
scrollEventSubscription.unsubscribe();
|
3058
|
+
newScrollableHostObservable.complete();
|
3059
|
+
}
|
3060
|
+
});
|
2976
3061
|
});
|
2977
|
-
return behaviorSubject;
|
2978
3062
|
};
|
2979
3063
|
SkyScrollableHostService.prototype.findScrollableHost = function (element) {
|
2980
3064
|
var regex = /(auto|scroll)/;
|
@@ -3447,7 +3531,7 @@
|
|
3447
3531
|
else {
|
3448
3532
|
this.scrollableHostWatchUnsubscribe = new rxjs.Subject();
|
3449
3533
|
}
|
3450
|
-
this.scrollableHostService.watchScrollableHost(this.el
|
3534
|
+
this.scrollableHostService.watchScrollableHost(this.el)
|
3451
3535
|
.pipe(operators.takeUntil(this.scrollableHostWatchUnsubscribe))
|
3452
3536
|
.subscribe(function (scrollableHost) {
|
3453
3537
|
var e_3, _a;
|