MCPcopy Create free account
hub / github.com/dajie111/nodeseek-userscript / onMouseMove

Function onMouseMove

notes.js:2627–2660  ·  view source on GitHub ↗
(moveEvent)

Source from the content-addressed store, hash-verified

2625 const aspectRatio = startWidth / startHeight;
2626
2627 const onMouseMove = (moveEvent) => {
2628 const deltaX = moveEvent.clientX - startX;
2629 const deltaY = moveEvent.clientY - startY;
2630
2631 // 根据x方向的变化计算新尺寸,保持宽高比
2632 let newWidth = Math.max(50, startWidth + deltaX);
2633 let newHeight = newWidth / aspectRatio;
2634
2635 // 计算可用的最大尺寸,避免遮挡底部按钮
2636 const maxWidth = editor.offsetWidth - 40;
2637 const bottomBar = editor.parentElement.querySelector('.nsn-bottom');
2638 const bottomBarHeight = bottomBar ? bottomBar.offsetHeight + 20 : 60;
2639 const maxHeight = editor.offsetHeight - bottomBarHeight;
2640
2641 // 限制最大宽度
2642 if (newWidth > maxWidth) {
2643 newWidth = maxWidth;
2644 newHeight = newWidth / aspectRatio;
2645 }
2646
2647 // 限制最大高度,避免遮挡底部按钮
2648 if (newHeight > maxHeight) {
2649 newHeight = maxHeight;
2650 newWidth = newHeight * aspectRatio;
2651 if (newWidth > maxWidth) {
2652 newWidth = maxWidth;
2653 newHeight = newWidth / aspectRatio;
2654 }
2655 }
2656
2657 img.style.width = newWidth + 'px';
2658 img.style.height = newHeight + 'px';
2659 img.style.maxWidth = 'none';
2660 };
2661
2662 const onMouseUp = (upEvent) => {
2663 handle._isDragging = false;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected