antd Drawer 实现宽度拖拽

ts 复制代码
import react from 'react '
const App = () => {
  const onmousedown = () => {
    let isDown = false
    isDown = true
    window.onmouseup = () => {
      isDown = false

      window.onmousemove = null
    }
    window.onmousemove = (e: any) => {
      if (isDown === false) {
        return
      }
      ;(document && document.getElementById('line')?.style?.left) ?? '0px'

      const d: any = document.getElementsByClassName('ant-drawer-content-wrapper')[0]
      const handle = document.body.clientWidth - e.clientX
      if (handle > document.body.clientWidth) {
        d.style.width = document.body.clientWidth + 'px'
        return
      }
      d.style.width = handle + 'px'
    }
  }
  return (
    <Drawer title="查看详情" open={open} placement="right" onClose={onClose} width="800px">
      <div id="line" onMouseDown={onmousedown} className="line"></div>
      <UserMenu />
    </Drawer>
  )
}

export default APP
相关推荐
GIS之路4 分钟前
GDAL 实现创建几何对象
前端
liulilittle18 分钟前
CLANG 交叉编译
linux·服务器·开发语言·前端·c++
自信阿杜33 分钟前
跨标签页数据同步完全指南:如何选择最优通信方案
前端·javascript
牛马11143 分钟前
WidgetsFlutterBinding.ensureInitialized()在 Flutter Web 端启动流程的影响
java·前端·flutter
Captaincc44 分钟前
2025: The year in LLMs
前端·vibecoding
指尖跳动的光1 小时前
Vue的nextTick()方法
前端·javascript·vue.js
码事漫谈1 小时前
可能,AI早都觉醒了
前端
qq_406176142 小时前
JS 事件循环(Event Loop)
开发语言·前端·javascript
Codebee2 小时前
ooder A2UI ES6版本正式发布:现代化模块架构,MIT开源许可
前端
Devin_chen2 小时前
4.前端使用Node + MongoDB + Langchain消息管理与聊天历史存储
前端·langchain