@pathscale/ui 0.0.148 → 0.0.149

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.
Files changed (2) hide show
  1. package/dist/index.js +96 -73
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10431,68 +10431,8 @@ const FloatingDock_DockItem = (props)=>{
10431
10431
  let iconRef;
10432
10432
  const [hovered, setHovered] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(false);
10433
10433
  const cfg = props.cfg;
10434
- const sW = createSpring(cfg.baseSize, cfg.springOpts);
10435
- const sH = createSpring(cfg.baseSize, cfg.springOpts);
10436
- const sIW = createSpring(cfg.iconSize, cfg.springOpts);
10437
- const sIH = createSpring(cfg.iconSize, cfg.springOpts);
10438
- let rafId;
10439
- let prevTime = 0;
10440
- let lastMousePos = 1 / 0;
10441
- let loopRunning = false;
10442
- const startLoop = ()=>{
10443
- if (loopRunning || !cfg.magnify) return;
10444
- loopRunning = true;
10445
- prevTime = 0;
10446
- rafId = requestAnimationFrame(tick);
10447
- };
10448
- const stopLoop = ()=>{
10449
- if (void 0 !== rafId) cancelAnimationFrame(rafId);
10450
- rafId = void 0;
10451
- loopRunning = false;
10452
- };
10453
- const tick = (time)=>{
10454
- const dt = prevTime ? Math.min((time - prevTime) / 1000, 0.05) : 1 / 60;
10455
- prevTime = time;
10456
- const mp = props.mousePos();
10457
- if (mp !== lastMousePos) {
10458
- lastMousePos = mp;
10459
- if (wrapRef) {
10460
- const b = wrapRef.getBoundingClientRect();
10461
- const isH = "horizontal" === cfg.orientation;
10462
- const center = isH ? b.x + b.width / 2 : b.y + b.height / 2;
10463
- const dist = Math.abs(mp - center);
10464
- const ts = mp === 1 / 0 ? cfg.baseSize : mapRange(dist, 0, cfg.magnifyRange, cfg.hoverSize, cfg.baseSize);
10465
- const ti = mp === 1 / 0 ? cfg.iconSize : mapRange(dist, 0, cfg.magnifyRange, cfg.hoverIconSize, cfg.iconSize);
10466
- sW.set(ts);
10467
- sH.set(ts);
10468
- sIW.set(ti);
10469
- sIH.set(ti);
10470
- }
10471
- }
10472
- sW.step(dt);
10473
- sH.step(dt);
10474
- sIW.step(dt);
10475
- sIH.step(dt);
10476
- if (wrapRef) {
10477
- wrapRef.style.width = `${sW.get()}px`;
10478
- wrapRef.style.height = `${sH.get()}px`;
10479
- }
10480
- if (iconRef) {
10481
- iconRef.style.width = `${sIW.get()}px`;
10482
- iconRef.style.height = `${sIH.get()}px`;
10483
- }
10484
- if (sW.settled() && sH.settled() && sIW.settled() && sIH.settled()) return void stopLoop();
10485
- rafId = requestAnimationFrame(tick);
10486
- };
10487
10434
  (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.onMount)(()=>{
10488
- if (!cfg.magnify) return;
10489
- (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
10490
- props.mousePos();
10491
- startLoop();
10492
- });
10493
- });
10494
- (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.onCleanup)(()=>{
10495
- stopLoop();
10435
+ if (wrapRef && iconRef) props.registerRefs(wrapRef, iconRef);
10496
10436
  });
10497
10437
  const handleClick = (e)=>{
10498
10438
  if (props.item.onClick) {
@@ -10503,10 +10443,7 @@ const FloatingDock_DockItem = (props)=>{
10503
10443
  const inner = (()=>{
10504
10444
  var _el$ = FloatingDock_tmpl$2(), _el$3 = _el$.firstChild;
10505
10445
  _el$.addEventListener("mouseleave", ()=>setHovered(false));
10506
- _el$.addEventListener("mouseenter", ()=>{
10507
- setHovered(true);
10508
- startLoop();
10509
- });
10446
+ _el$.addEventListener("mouseenter", ()=>setHovered(true));
10510
10447
  var _ref$ = wrapRef;
10511
10448
  "function" == typeof _ref$ ? (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.use)(_ref$, _el$) : wrapRef = _el$;
10512
10449
  (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.insert)(_el$, (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(__WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.Show, {
@@ -10574,6 +10511,82 @@ const FloatingDock_DockItem = (props)=>{
10574
10511
  const FloatingDockDesktop = (props)=>{
10575
10512
  const [mousePos, setMousePos] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(1 / 0);
10576
10513
  const isH = ()=>"horizontal" === props.cfg.orientation;
10514
+ const cfg = props.cfg;
10515
+ const itemSprings = [];
10516
+ let rafId;
10517
+ let prevTime = 0;
10518
+ let lastMousePos = 1 / 0;
10519
+ let loopRunning = false;
10520
+ const startLoop = ()=>{
10521
+ if (loopRunning || !cfg.magnify) return;
10522
+ loopRunning = true;
10523
+ prevTime = 0;
10524
+ rafId = requestAnimationFrame(tick);
10525
+ };
10526
+ const stopLoop = ()=>{
10527
+ if (void 0 !== rafId) cancelAnimationFrame(rafId);
10528
+ rafId = void 0;
10529
+ loopRunning = false;
10530
+ };
10531
+ const tick = (time)=>{
10532
+ const dt = prevTime ? Math.min((time - prevTime) / 1000, 0.05) : 1 / 60;
10533
+ prevTime = time;
10534
+ const mp = mousePos();
10535
+ if (mp !== lastMousePos) {
10536
+ lastMousePos = mp;
10537
+ const centers = [];
10538
+ for(let i = 0; i < itemSprings.length; i++){
10539
+ const wrap = itemSprings[i].wrapRef;
10540
+ if (wrap) {
10541
+ const b = wrap.getBoundingClientRect();
10542
+ centers[i] = isH() ? b.x + b.width / 2 : b.y + b.height / 2;
10543
+ } else centers[i] = 0;
10544
+ }
10545
+ for(let i = 0; i < itemSprings.length; i++){
10546
+ const s = itemSprings[i];
10547
+ if (!s.wrapRef) continue;
10548
+ const dist = Math.abs(mp - centers[i]);
10549
+ const ts = mp === 1 / 0 ? cfg.baseSize : mapRange(dist, 0, cfg.magnifyRange, cfg.hoverSize, cfg.baseSize);
10550
+ const ti = mp === 1 / 0 ? cfg.iconSize : mapRange(dist, 0, cfg.magnifyRange, cfg.hoverIconSize, cfg.iconSize);
10551
+ s.sW.set(ts);
10552
+ s.sH.set(ts);
10553
+ s.sIW.set(ti);
10554
+ s.sIH.set(ti);
10555
+ }
10556
+ }
10557
+ let allSettled = true;
10558
+ for(let i = 0; i < itemSprings.length; i++){
10559
+ const s = itemSprings[i];
10560
+ s.sW.step(dt);
10561
+ s.sH.step(dt);
10562
+ s.sIW.step(dt);
10563
+ s.sIH.step(dt);
10564
+ if (allSettled && !(s.sW.settled() && s.sH.settled() && s.sIW.settled() && s.sIH.settled())) allSettled = false;
10565
+ }
10566
+ for(let i = 0; i < itemSprings.length; i++){
10567
+ const s = itemSprings[i];
10568
+ if (s.wrapRef) {
10569
+ s.wrapRef.style.width = `${s.sW.get()}px`;
10570
+ s.wrapRef.style.height = `${s.sH.get()}px`;
10571
+ }
10572
+ if (s.iconRef) {
10573
+ s.iconRef.style.width = `${s.sIW.get()}px`;
10574
+ s.iconRef.style.height = `${s.sIH.get()}px`;
10575
+ }
10576
+ }
10577
+ if (allSettled) return void stopLoop();
10578
+ rafId = requestAnimationFrame(tick);
10579
+ };
10580
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.onMount)(()=>{
10581
+ if (!cfg.magnify) return;
10582
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
10583
+ mousePos();
10584
+ startLoop();
10585
+ });
10586
+ });
10587
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.onCleanup)(()=>{
10588
+ stopLoop();
10589
+ });
10577
10590
  return (()=>{
10578
10591
  var _el$6 = FloatingDock_tmpl$5();
10579
10592
  _el$6.addEventListener("mouseleave", ()=>setMousePos(1 / 0));
@@ -10582,23 +10595,33 @@ const FloatingDockDesktop = (props)=>{
10582
10595
  get each () {
10583
10596
  return props.items;
10584
10597
  },
10585
- children: (item)=>(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(FloatingDock_DockItem, {
10598
+ children: (item, idx)=>{
10599
+ const springs = {
10600
+ sW: createSpring(cfg.baseSize, cfg.springOpts),
10601
+ sH: createSpring(cfg.baseSize, cfg.springOpts),
10602
+ sIW: createSpring(cfg.iconSize, cfg.springOpts),
10603
+ sIH: createSpring(cfg.iconSize, cfg.springOpts)
10604
+ };
10605
+ itemSprings[idx()] = springs;
10606
+ return (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(FloatingDock_DockItem, {
10586
10607
  item: item,
10587
- mousePos: mousePos,
10588
- get cfg () {
10589
- return props.cfg;
10608
+ cfg: cfg,
10609
+ registerRefs: (wrap, icon)=>{
10610
+ springs.wrapRef = wrap;
10611
+ springs.iconRef = icon;
10590
10612
  }
10591
- })
10613
+ });
10614
+ }
10592
10615
  }));
10593
10616
  (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.effect)((_p$)=>{
10594
10617
  var _v$6 = twMerge("mx-auto", "items-center", props.showContainer && "rounded-2xl bg-base-100 shadow-[0px_1px_0px_0px_var(--color-base-300)_inset,0px_1px_0px_0px_var(--color-base-100)]", isH() && props.showContainer && "px-4 py-2", !isH() && props.showContainer && "py-4 px-2", props.class), _v$7 = {
10595
10618
  display: "flex",
10596
10619
  "flex-direction": isH() ? "row" : "column",
10597
- gap: `${props.cfg.gap}px`,
10620
+ gap: `${cfg.gap}px`,
10598
10621
  ...isH() ? {
10599
- height: `${props.cfg.baseSize + 16}px`
10622
+ height: `${cfg.baseSize + 16}px`
10600
10623
  } : {
10601
- width: `${props.cfg.baseSize + 16}px`
10624
+ width: `${cfg.baseSize + 16}px`
10602
10625
  },
10603
10626
  overflow: "visible"
10604
10627
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pathscale/ui",
3
- "version": "0.0.148",
3
+ "version": "0.0.149",
4
4
  "author": "pathscale",
5
5
  "repository": {
6
6
  "type": "git",