tgui-core 4.2.3 → 4.3.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.
|
@@ -12,6 +12,25 @@ type Props = {
|
|
|
12
12
|
initialTop: number;
|
|
13
13
|
/** Padding applied to the right of the zoom controls */
|
|
14
14
|
zoomPadding: number;
|
|
15
|
+
/**
|
|
16
|
+
* Minimum level of zoom possible
|
|
17
|
+
* @default 0.5
|
|
18
|
+
*/
|
|
19
|
+
minimumZoom: number;
|
|
20
|
+
/**
|
|
21
|
+
* Maximum level of zoom possible
|
|
22
|
+
* @default 1.5
|
|
23
|
+
*/
|
|
24
|
+
maximumZoom: number;
|
|
25
|
+
/**
|
|
26
|
+
* Increments by which zoom level changes every scroll/button click
|
|
27
|
+
* @default 0.1
|
|
28
|
+
*/
|
|
29
|
+
zoomIncrement: number;
|
|
30
|
+
/** X position to snap to. When this value is changed, the element will snap to said position */
|
|
31
|
+
zoomToX: number;
|
|
32
|
+
/** Y position to snap to. When this value is changed, the element will snap to said position */
|
|
33
|
+
zoomToY: number;
|
|
15
34
|
/** A callback function that is called when the background image is moved. */
|
|
16
35
|
onBackgroundMoved: (newX: number, newY: number) => void;
|
|
17
36
|
/** A callback function that is called when the zoom value changes. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{computeBoxProps as n}from"../common/ui.js";import{useEffect as i,useRef as o,useState as r}from"react";import{Button as s}from"./Button.js";import{ProgressBar as l}from"./ProgressBar.js";import{Stack as a}from"./Stack.js";function c(s){let{backgroundImage:l,children:a,imageWidth:c,zoomPadding:d=0,initialLeft:m=0,initialTop:f=0,minimumZoom:p=.5,maximumZoom:h=1.5,zoomIncrement:v=.1,zoomToX:g=m,zoomToY:w=f,onBackgroundMoved:x,onZoomChange:b,...$}=s,[k,M]=r(m),[Y,j]=r(f),[y,I]=r(m),[z,E]=r(f),[X,C]=r(!1),[D,P]=r(1),Z=o(null);function B(e){M(e.clientX-y),j(e.clientY-z),C(!0)}function L(e){if(!X)return;let t=e.clientX-k,n=e.clientY-Y;x?.(t,n),I(t),E(n)}function S(){C(!1)}function V(e,t,n){if("increase"===e&&D>=h||"decrease"===e&&D<=p)return;let i=Math.round((D+("increase"===e?v:-v))*10)/10;P(i),I((y-t)/D*i+t),E((z-n)*i+n),b?.(i)}return i(()=>(window.addEventListener("mouseup",S),()=>{window.removeEventListener("mouseup",S)}),[]),i(()=>{void 0!==g&&void 0!==w&&(I(g),E(w))},[g,w]),t("div",{...n({...$,style:{...$.style,height:"100%",overflow:"hidden",position:"relative",width:"100%"}}),ref:Z,children:[e("div",{onMouseDown:B,onMouseMove:L,onWheel:function(e){0!==e.deltaY&&(e.preventDefault(),V(e.deltaY<0?"increase":"decrease",e.nativeEvent.offsetX,e.nativeEvent.offsetY))},style:{backgroundImage:`url("${l}")`,backgroundPosition:`${y}px ${z}px`,backgroundRepeat:"repeat",backgroundSize:`${D*c}px`,transition:`${X?"0s":"0.075s"} linear`,height:"100%",inset:0,position:"absolute",width:"100%"}}),e("div",{onMouseDown:B,onMouseMove:L,style:{height:"100%",inset:0,position:"absolute",transform:`translate(${y}px, ${z}px) scale(${D})`,transition:`${X?"0s":"0.075s"} linear`,transformOrigin:"top left",width:"100%"},children:a}),e(u,{padding:d,minimumZoom:p,maximumZoom:h,zoomX:(Z.current?.offsetWidth||0)/2,zoomY:(Z.current?.offsetHeight||0)/2,onZoomClick:V,zoom:D})]})}function u(n){let{zoom:i,padding:o,onZoomClick:r,minimumZoom:c,maximumZoom:u,zoomX:d,zoomY:m}=n;return e("div",{style:{left:5,position:"absolute",right:5+o,top:5},children:t(a,{children:[e(a.Item,{children:e(s,{disabled:i<=c,icon:"minus",onClick:()=>r("decrease",d,m)})}),e(a.Item,{grow:!0,children:t(l,{maxValue:u,minValue:c,value:i,children:[i,"x"]})}),e(a.Item,{children:e(s,{disabled:i>=u,icon:"plus",onClick:()=>r("increase",d,m)})})]})})}export{c as InfinitePlane};
|
package/package.json
CHANGED