@arco-design/transformable

中文文档
1.0.2发布于 2022/06/05MITESM + CJS零依赖近 30 天下载 5436

novel-fe transformable module

原始使用文档
文档目录4 节
  1. Preview
  2. Installation
  3. Quick Start
  4. Options

#Transformable - Powerful 2D Gesture Anim Solution

Preview


Effect Preview

Installation


Available as an npm package

// with npm
npm install @arco-design/transformable

// with yarn
yarn add @arco-design/transformable

Quick Start


import TransformAble from '@arco-design/transformable';

function MyComponent() {
    const domRef = useRef(null);
    const controllerRef = useRef(null);
    useEffect(() => {
        controllerRef.current = new TransformAble({
            dom: this.dom,
            onTransform: (state) => {
                const { translateX, translateY, scale, transformOrigin } = state;
                // DO SOMETHING IF NECESSARY
            },
        });
    }, []);
    function resetDom() {
        controllerRef.current.zoomTo(1, {
            fitEdge: true,
        });
    }
    return (
        <div className="transform-container"
            style={{ overflow: 'hidden' }}
        >
            <div
                className="transform-demo-object"
                ref={domRef}
            >
            <Button onClick={resetDom}>reset</Button>
        </div>
    )
}

Options


All this options can be dynamic changed by calling .config()

NameTypeDefaultDecription
activebooleantrueinteractive avaiable status flag
maxScalenumber2max scale limit
minScalenumber0.5min scale limit
preventScrollbooleantruetriggle e.preventDefault since touch, in order to prevent scroll dom behavior
domHTMLElementnulltransform & interactive target
useDomBoundarybooleantruedecide how to compute target boundary for collision detection (inside edge).
true: use dom.getBoundingClientRect when dom set;
false: manually set by .setBoundary()
bouncingnumber300scale bouncing animation duration(ms)
dampnumber2momentum-based scrolling option, speed decreasement per frame, default as 2px/frame
bounceRateXnumber0drag damping [translate offset / touch offset] when drag(x-axis) out of viewport, set (0, 1] value to enable dragging out of edge with damping effect and rebound animation
bounceRateXnumber0drag damping [translate offset / touch offset] when drag(y-axis) out of viewport, same to above
motionThresholdnumber10min speed for genreate momentum-based scrollin effect, default as 10px/frame
fixedXbooleanfalsedisable x-axis dragging
fixedYbooleanfalsedisable y-axis dragging
dragModestring'hybrid'drag effect mode.
'always': enable dragging without scaling;
'hybrid': enable drag only if scaled;
'none': no dragging
swipeModestring'animation'decide how to implement momentum-based scrolling animation.
'animation': insert <style> css declaration when animation triggered;
'transition': use transition ease function when animation triggered
transformModestring'translate-first'animation effect may be different when dragging & scaling both.
'translate-first': set css property transform as translate()scale();
'scale-first': set transform as scale()translate();
'matrix': set transform as matrix()
cubicobject{
scroll: [.33, 1, .66, 1],
bounce: [.17, 1, .17, 1],
}
anim easing function (cubic-bezier) of scroll/bounce effect
viewportobject{
left: 0,
right: screenWidth,
top: 0,
bottom: screenHeight
}
viewport scope for collision detection, the edge is defined as viewport ∩ boundary

版本与发布记录

@arco-design/transformable 共发布 1 个版本,首次发布于 2022/06/05;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.2latest2022/06/054 年前

关于 @arco-design/transformable 的常见问题

@arco-design/transformable 是什么?

novel-fe transformable module

如何安装 @arco-design/transformable?

在项目目录运行 npm install @arco-design/transformable,或使用 pnpm add / yarn add / bun add。

@arco-design/transformable 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/arco-design__transformable 是否存在。

@arco-design/transformable 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@arco-design/transformable 可以商用吗?

@arco-design/transformable 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@arco-design/transformable 的下载量有多少?

根据 npm 官方下载统计,@arco-design/transformable 在 2026/10/07 – 2026/11/05 这 30 天内被下载 5,436 次,日均约 181 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@arco-design/transformable 还在维护吗?

最新版本 1.0.2 发布于 2022/06/05(4 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/06/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。