@pathscale/ui 0.0.128 → 0.0.129
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.
|
@@ -3,6 +3,7 @@ import type { IComponentBaseProps } from "../types";
|
|
|
3
3
|
export interface UseImmersiveLandingOptions {
|
|
4
4
|
pages: readonly string[];
|
|
5
5
|
initialPage?: string;
|
|
6
|
+
currentPage?: Accessor<string>;
|
|
6
7
|
transitionDuration?: number;
|
|
7
8
|
onNavigate?: (fromPage: string, toPage: string) => void;
|
|
8
9
|
onNavigationComplete?: (page: string) => void;
|
|
@@ -37,6 +38,7 @@ export interface ImmersiveLandingContextValue {
|
|
|
37
38
|
export interface ImmersiveLandingProps extends IComponentBaseProps {
|
|
38
39
|
pages: readonly string[];
|
|
39
40
|
initialPage?: string;
|
|
41
|
+
currentPage?: Accessor<string>;
|
|
40
42
|
transitionDuration?: number;
|
|
41
43
|
onNavigate?: (fromPage: string, toPage: string) => void;
|
|
42
44
|
onNavigationComplete?: (page: string) => void;
|
package/dist/index.js
CHANGED
|
@@ -10623,13 +10623,34 @@ const HeroNamespaces = Object.assign(Hero, {
|
|
|
10623
10623
|
});
|
|
10624
10624
|
const hero_Hero = HeroNamespaces;
|
|
10625
10625
|
function useImmersiveLanding(options) {
|
|
10626
|
-
const { pages, initialPage = pages[0], transitionDuration = 400, onNavigate, onNavigationComplete, enableScrollNavigation = true } = options;
|
|
10627
|
-
const
|
|
10626
|
+
const { pages, initialPage = pages[0], currentPage: controlledPage, transitionDuration = 400, onNavigate, onNavigationComplete, enableScrollNavigation = true } = options;
|
|
10627
|
+
const isControlled = !!controlledPage;
|
|
10628
|
+
const [internalPage, setInternalPage] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(initialPage);
|
|
10628
10629
|
const [isTransitioning, setIsTransitioning] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(false);
|
|
10629
10630
|
const [direction, setDirection] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(null);
|
|
10631
|
+
const activePage = isControlled ? controlledPage : internalPage;
|
|
10630
10632
|
const currentIndex = ()=>pages.indexOf(activePage());
|
|
10631
10633
|
const isFirstPage = ()=>0 === currentIndex();
|
|
10632
10634
|
const isLastPage = ()=>currentIndex() === pages.length - 1;
|
|
10635
|
+
if (isControlled) {
|
|
10636
|
+
let prevPage = controlledPage();
|
|
10637
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
|
|
10638
|
+
const next = controlledPage();
|
|
10639
|
+
if (next !== prevPage && !isTransitioning()) {
|
|
10640
|
+
const fromIndex = pages.indexOf(prevPage);
|
|
10641
|
+
const toIndex = pages.indexOf(next);
|
|
10642
|
+
if (toIndex >= 0) {
|
|
10643
|
+
setDirection(toIndex > fromIndex ? "next" : "prev");
|
|
10644
|
+
setIsTransitioning(true);
|
|
10645
|
+
setTimeout(()=>{
|
|
10646
|
+
setIsTransitioning(false);
|
|
10647
|
+
setDirection(null);
|
|
10648
|
+
}, transitionDuration);
|
|
10649
|
+
}
|
|
10650
|
+
prevPage = next;
|
|
10651
|
+
}
|
|
10652
|
+
});
|
|
10653
|
+
}
|
|
10633
10654
|
const navigateToInternal = (pageId)=>{
|
|
10634
10655
|
if (isTransitioning() || !pages.includes(pageId)) return;
|
|
10635
10656
|
if (pageId === activePage()) return;
|
|
@@ -10638,7 +10659,7 @@ function useImmersiveLanding(options) {
|
|
|
10638
10659
|
const toIndex = pages.indexOf(pageId);
|
|
10639
10660
|
setDirection(toIndex > fromIndex ? "next" : "prev");
|
|
10640
10661
|
setIsTransitioning(true);
|
|
10641
|
-
|
|
10662
|
+
if (!isControlled) setInternalPage(pageId);
|
|
10642
10663
|
if (onNavigate) onNavigate(fromPage, pageId);
|
|
10643
10664
|
setTimeout(()=>{
|
|
10644
10665
|
setIsTransitioning(false);
|
|
@@ -10945,6 +10966,7 @@ const ImmersiveLanding = (props)=>{
|
|
|
10945
10966
|
const [local, others] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.splitProps)(props, [
|
|
10946
10967
|
"pages",
|
|
10947
10968
|
"initialPage",
|
|
10969
|
+
"currentPage",
|
|
10948
10970
|
"transitionDuration",
|
|
10949
10971
|
"onNavigate",
|
|
10950
10972
|
"onNavigationComplete",
|
|
@@ -10961,6 +10983,7 @@ const ImmersiveLanding = (props)=>{
|
|
|
10961
10983
|
const navigation = useImmersiveLanding({
|
|
10962
10984
|
pages: local.pages,
|
|
10963
10985
|
initialPage: local.initialPage,
|
|
10986
|
+
currentPage: local.currentPage,
|
|
10964
10987
|
transitionDuration: local.transitionDuration,
|
|
10965
10988
|
onNavigate: local.onNavigate,
|
|
10966
10989
|
onNavigationComplete: local.onNavigationComplete,
|