mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-11-30 08:33:37 +08:00
13 lines
5.7 KiB
JavaScript
13 lines
5.7 KiB
JavaScript
import{_ as a,o as t,c as i,a3 as e}from"./chunks/framework.BNdm2jZV.js";const c=JSON.parse('{"title":"RDraggableCard","description":"","frontmatter":{},"headers":[],"relativePath":"reference/components/draggable-card.md","filePath":"reference/components/draggable-card.md"}'),d={name:"reference/components/draggable-card.md"};function n(l,s,r,h,p,o){return t(),i("div",null,[...s[0]||(s[0]=[e(`<h1 id="rdraggablecard" tabindex="-1">RDraggableCard <a class="header-anchor" href="#rdraggablecard" aria-label="Permalink to "RDraggableCard""></a></h1><p>基于 Naive UI Card 和 Interact.js。卡片 Teleport 到应用创建的容器,不参加原父节点的普通布局流。设置标题后可拖动卡片头部,否则拖动内容区;组件没有开放改变尺寸的交互。</p><table tabindex="0"><thead><tr><th>属性</th><th>默认</th><th>说明</th></tr></thead><tbody><tr><td><code>dad</code></td><td><code>true</code></td><td>是否启用拖拽。</td></tr><tr><td><code>restrictionElement</code></td><td><code>'body'</code></td><td>拖动边界,支持 CSS 选择器、元素或可解包的目标;选择器取第一个匹配。</td></tr><tr><td><code>restrictRectOptions</code></td><td>默认边界,<code>endOnly: true</code></td><td>覆盖 Interact.js 边界限制。</td></tr><tr><td><code>defaultPosition</code></td><td><code>{ x: 0, y: 0 }</code></td><td>相对限制容器的偏移,或预设位置。</td></tr><tr><td><code>padding</code></td><td>无</td><td>初次定位时相对边界的 <code>{ x, y }</code> 间距。</td></tr><tr><td><code>width</code> / <code>zIndex</code></td><td><code>600</code> / 无</td><td>卡片宽度与层级。</td></tr><tr><td><code>animation</code></td><td><code>false</code></td><td>启用进场过渡。</td></tr></tbody></table><p>位置可用 <code>top-left</code>、<code>top-right</code>、<code>bottom-left</code>、<code>bottom-right</code>、<code>center</code>、<code>top-center</code>、<code>bottom-center</code>。替换 <code>defaultPosition</code> 引用会触发重定位;没有公开拖拽事件或位置持久化。选择器需要在布局中真实存在,容器应有明确尺寸。组件初始化会访问 <code>document</code>,仅在浏览器侧渲染。继承 Card 属性和插槽。</p><div class="language-tsx vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">tsx</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { RDraggableCard } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> '@/components'</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> const</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> renderFloatingHelp</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> () </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> <</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">RDraggableCard</span></span>
|
||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> title</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"帮助"</span></span>
|
||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> width</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">320</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span>
|
||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> defaultPosition</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"bottom-right"</span></span>
|
||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> padding</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{{ x: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">24</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, y: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">24</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }}</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ></span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 拖动标题可移动此卡片</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> </</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">RDraggableCard</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">></span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div><p><a href="https://github.com/XiaoDaiGua-Ray/ray-template/blob/403fdd589abbe37b38e1240d34f8daf2a60d3690/packages/ui/src/RDraggableCard/DraggableCard.tsx" target="_blank" rel="noreferrer">组件源码</a></p>`,6)])])}const g=a(d,[["render",n]]);export{c as __pageData,g as default};
|