@ethlete/core 1.5.0 → 1.6.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/esm2020/lib/services/viewport.service.mjs +4 -4
- package/esm2020/lib/utils/scrollable.utils.mjs +81 -1
- package/fesm2015/ethlete-core.mjs +83 -3
- package/fesm2015/ethlete-core.mjs.map +1 -1
- package/fesm2020/ethlete-core.mjs +83 -3
- package/fesm2020/ethlete-core.mjs.map +1 -1
- package/lib/directives/animated-lifecycle/animated-lifecycle.directive.d.ts +2 -2
- package/lib/services/viewport.service.d.ts +1 -1
- package/lib/utils/scrollable.utils.d.ts +49 -0
- package/package.json +1 -1
|
@@ -862,6 +862,86 @@ const elementCanScroll = (element) => {
|
|
|
862
862
|
const { scrollHeight, clientHeight, scrollWidth, clientWidth } = element;
|
|
863
863
|
return scrollHeight > clientHeight || scrollWidth > clientWidth;
|
|
864
864
|
};
|
|
865
|
+
const isElementVisible = (options) => {
|
|
866
|
+
let { container } = options;
|
|
867
|
+
const { element } = options;
|
|
868
|
+
if (!element || container === null) {
|
|
869
|
+
return null;
|
|
870
|
+
}
|
|
871
|
+
container || (container = document.documentElement);
|
|
872
|
+
const canScroll = elementCanScroll(container);
|
|
873
|
+
if (!canScroll) {
|
|
874
|
+
return { inline: true, block: true };
|
|
875
|
+
}
|
|
876
|
+
const elementRect = element.getBoundingClientRect();
|
|
877
|
+
const containerRect = container.getBoundingClientRect();
|
|
878
|
+
const elementInlineStart = elementRect.left;
|
|
879
|
+
const elementBlockStart = elementRect.top;
|
|
880
|
+
const containerInlineStart = containerRect.left;
|
|
881
|
+
const containerBlockStart = containerRect.top;
|
|
882
|
+
const elementInlineEnd = elementInlineStart + elementRect.width;
|
|
883
|
+
const elementBlockEnd = elementBlockStart + elementRect.height;
|
|
884
|
+
const containerInlineEnd = containerInlineStart + containerRect.width;
|
|
885
|
+
const containerBlockEnd = containerBlockStart + containerRect.height;
|
|
886
|
+
const isElementInlineVisible = elementInlineStart >= containerInlineStart && elementInlineEnd <= containerInlineEnd;
|
|
887
|
+
const isElementBlockVisible = elementBlockStart >= containerBlockStart && elementBlockEnd <= containerBlockEnd;
|
|
888
|
+
return { inline: isElementInlineVisible, block: isElementBlockVisible };
|
|
889
|
+
};
|
|
890
|
+
const scrollToElement = (options) => {
|
|
891
|
+
let { container } = options;
|
|
892
|
+
const { element, direction, behavior = 'smooth', origin = 'nearest' } = options;
|
|
893
|
+
if (!element || container === null) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
container || (container = document.documentElement);
|
|
897
|
+
const canScroll = elementCanScroll(container);
|
|
898
|
+
if (!canScroll) {
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
const elementRect = element.getBoundingClientRect();
|
|
902
|
+
const containerRect = container.getBoundingClientRect();
|
|
903
|
+
const elementInlineSize = elementRect.width;
|
|
904
|
+
const elementBlockSize = elementRect.height;
|
|
905
|
+
const containerInlineSize = containerRect.width;
|
|
906
|
+
const containerBlockSize = containerRect.height;
|
|
907
|
+
const elementInlineStart = elementRect.left;
|
|
908
|
+
const elementBlockStart = elementRect.top;
|
|
909
|
+
const containerInlineStart = containerRect.left;
|
|
910
|
+
const containerBlockStart = containerRect.top;
|
|
911
|
+
const elementInlineEnd = elementInlineStart + elementInlineSize;
|
|
912
|
+
const elementBlockEnd = elementBlockStart + elementBlockSize;
|
|
913
|
+
const containerInlineEnd = containerInlineStart + containerInlineSize;
|
|
914
|
+
const containerBlockEnd = containerBlockStart + containerBlockSize;
|
|
915
|
+
const elementInlineCenter = elementInlineStart + elementInlineSize / 2;
|
|
916
|
+
const elementBlockCenter = elementBlockStart + elementBlockSize / 2;
|
|
917
|
+
const containerInlineCenter = containerInlineStart + containerInlineSize / 2;
|
|
918
|
+
const containerBlockCenter = containerBlockStart + containerBlockSize / 2;
|
|
919
|
+
const elementInlineOrigin = origin === 'center' ? elementInlineCenter : origin === 'end' ? elementInlineEnd : elementInlineStart;
|
|
920
|
+
const elementBlockOrigin = origin === 'center' ? elementBlockCenter : origin === 'end' ? elementBlockEnd : elementBlockStart;
|
|
921
|
+
const containerInlineOrigin = origin === 'center' ? containerInlineCenter : origin === 'end' ? containerInlineEnd : containerInlineStart;
|
|
922
|
+
const containerBlockOrigin = origin === 'center' ? containerBlockCenter : origin === 'end' ? containerBlockEnd : containerBlockStart;
|
|
923
|
+
const inlineOffset = elementInlineOrigin - containerInlineOrigin;
|
|
924
|
+
const blockOffset = elementBlockOrigin - containerBlockOrigin;
|
|
925
|
+
let inlineScroll = direction === 'block' ? undefined : inlineOffset;
|
|
926
|
+
let blockScroll = direction === 'inline' ? undefined : blockOffset;
|
|
927
|
+
if (origin === 'nearest') {
|
|
928
|
+
const elVisible = isElementVisible({ element, container });
|
|
929
|
+
if (elVisible?.inline && elVisible?.block) {
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
if (elVisible?.inline) {
|
|
933
|
+
inlineScroll = undefined;
|
|
934
|
+
}
|
|
935
|
+
if (elVisible?.block) {
|
|
936
|
+
blockScroll = undefined;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
container.scrollTo({
|
|
940
|
+
left: inlineScroll,
|
|
941
|
+
top: blockScroll,
|
|
942
|
+
behavior,
|
|
943
|
+
});
|
|
944
|
+
};
|
|
865
945
|
|
|
866
946
|
const scrollBehaviorSupported = supportsScrollBehavior();
|
|
867
947
|
class SmartBlockScrollStrategy {
|
|
@@ -1092,13 +1172,13 @@ class ViewportService {
|
|
|
1092
1172
|
this._isLg$ = new BehaviorSubject(false);
|
|
1093
1173
|
this._isXl$ = new BehaviorSubject(false);
|
|
1094
1174
|
this._is2Xl$ = new BehaviorSubject(false);
|
|
1095
|
-
this.currentViewport$ = combineLatest([this.isXs$, this.isSm$, this.isMd$, this.isLg$, this.isXl$, this.is2Xl$]).pipe(map((val) => this.getCurrentViewport(val)), shareReplay());
|
|
1175
|
+
this.currentViewport$ = combineLatest([this.isXs$, this.isSm$, this.isMd$, this.isLg$, this.isXl$, this.is2Xl$]).pipe(map((val) => this.getCurrentViewport(val)), shareReplay(1));
|
|
1096
1176
|
this._viewportConfig = _viewportConfig || DEFAULT_VIEWPORT_CONFIG;
|
|
1097
1177
|
this._observeDefaultBreakpoints();
|
|
1098
1178
|
}
|
|
1099
1179
|
observe(options) {
|
|
1100
1180
|
const mediaQuery = this._buildMediaQuery(options);
|
|
1101
|
-
return this._breakpointObserver.observe(mediaQuery).pipe(map((x) => x.matches), shareReplay());
|
|
1181
|
+
return this._breakpointObserver.observe(mediaQuery).pipe(map((x) => x.matches), shareReplay(1));
|
|
1102
1182
|
}
|
|
1103
1183
|
isMatched(options) {
|
|
1104
1184
|
const mediaQuery = this._buildMediaQuery(options);
|
|
@@ -2639,5 +2719,5 @@ const Validators = {
|
|
|
2639
2719
|
* Generated bundle index. Do not edit.
|
|
2640
2720
|
*/
|
|
2641
2721
|
|
|
2642
|
-
export { ANIMATABLE_TOKEN, ANIMATED_LIFECYCLE_TOKEN, AnimatableDirective, AnimatedLifecycleDirective, BehaviorSubjectWithSubscriberCount, ClickObserverFactory, ClickObserverService, ClickOutsideDirective, ContentObserverService, CursorDragScrollDirective, DEFAULT_VIEWPORT_CONFIG, DestroyService, FocusVisibleService, IS_ARRAY_NOT_EMPTY, IS_EMAIL, IsArrayNotEmpty, IsEmail, LetContext, LetDirective, MUST_MATCH, Memo, MustMatch, MutationObserverFactory, NormalizeGameResultTypePipe, NormalizeMatchParticipantsPipe, NormalizeMatchScorePipe, NormalizeMatchStatePipe, NormalizeMatchTypePipe, OBSERVE_SCROLL_STATE, ObserveContentDirective, ObserveResizeDirective, ObserveScrollStateDirective, RepeatDirective, ResizeObserverFactory, ResizeObserverService, RouterStateService, SCROLL_OBSERVER_FIRST_ELEMENT_CLASS, SCROLL_OBSERVER_IGNORE_TARGET_CLASS, SCROLL_OBSERVER_LAST_ELEMENT_CLASS, SEO_DIRECTIVE_TOKEN, ScrollObserverFirstElementDirective, ScrollObserverIgnoreTargetDirective, ScrollObserverLastElementDirective, SeoDirective, SmartBlockScrollStrategy, StructuredDataComponent, ToArrayPipe, TypedQueryList, VIEWPORT_CONFIG, Validators, ViewportService, clamp, clone, createFlipAnimation, createFlipAnimationGroup, createMediaQueryObservable, createReactiveBindings, deleteCookie, elementCanScroll, equal, forceReflow, fromNextFrame, getCookie, getDomain, getGroupMatchPoints, getGroupMatchScore, getKnockoutMatchScore, getMatchScoreSubLine, hasCookie, isGroupMatch, isKnockoutMatch, mergeSeoConfig, nextFrame, normalizeGameResultType, normalizeMatchParticipant, normalizeMatchParticipants, normalizeMatchScore, normalizeMatchState, normalizeMatchType, provideViewportConfig, routerDisableScrollTop, setCookie, toArray, toArrayTrackByFn };
|
|
2722
|
+
export { ANIMATABLE_TOKEN, ANIMATED_LIFECYCLE_TOKEN, AnimatableDirective, AnimatedLifecycleDirective, BehaviorSubjectWithSubscriberCount, ClickObserverFactory, ClickObserverService, ClickOutsideDirective, ContentObserverService, CursorDragScrollDirective, DEFAULT_VIEWPORT_CONFIG, DestroyService, FocusVisibleService, IS_ARRAY_NOT_EMPTY, IS_EMAIL, IsArrayNotEmpty, IsEmail, LetContext, LetDirective, MUST_MATCH, Memo, MustMatch, MutationObserverFactory, NormalizeGameResultTypePipe, NormalizeMatchParticipantsPipe, NormalizeMatchScorePipe, NormalizeMatchStatePipe, NormalizeMatchTypePipe, OBSERVE_SCROLL_STATE, ObserveContentDirective, ObserveResizeDirective, ObserveScrollStateDirective, RepeatDirective, ResizeObserverFactory, ResizeObserverService, RouterStateService, SCROLL_OBSERVER_FIRST_ELEMENT_CLASS, SCROLL_OBSERVER_IGNORE_TARGET_CLASS, SCROLL_OBSERVER_LAST_ELEMENT_CLASS, SEO_DIRECTIVE_TOKEN, ScrollObserverFirstElementDirective, ScrollObserverIgnoreTargetDirective, ScrollObserverLastElementDirective, SeoDirective, SmartBlockScrollStrategy, StructuredDataComponent, ToArrayPipe, TypedQueryList, VIEWPORT_CONFIG, Validators, ViewportService, clamp, clone, createFlipAnimation, createFlipAnimationGroup, createMediaQueryObservable, createReactiveBindings, deleteCookie, elementCanScroll, equal, forceReflow, fromNextFrame, getCookie, getDomain, getGroupMatchPoints, getGroupMatchScore, getKnockoutMatchScore, getMatchScoreSubLine, hasCookie, isElementVisible, isGroupMatch, isKnockoutMatch, mergeSeoConfig, nextFrame, normalizeGameResultType, normalizeMatchParticipant, normalizeMatchParticipants, normalizeMatchScore, normalizeMatchState, normalizeMatchType, provideViewportConfig, routerDisableScrollTop, scrollToElement, setCookie, toArray, toArrayTrackByFn };
|
|
2643
2723
|
//# sourceMappingURL=ethlete-core.mjs.map
|