-
Notifications
You must be signed in to change notification settings - Fork 4k
feat(module:resizable): support for multiple cursor types #8042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(module:resizable): support for multiple cursor types #8042
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8042 +/- ##
==========================================
- Coverage 91.64% 91.63% -0.02%
==========================================
Files 515 515
Lines 17640 17637 -3
Branches 2790 2790
==========================================
- Hits 16167 16161 -6
- Misses 1175 1178 +3
Partials 298 298
|
The cursor is the same as the window resize cursor. for this change, I think it should only apply when the cursor is at the edge of the resizeable box. like [Grid] and [Layout] in the demos. |
我们可以为 type NzScene = 'window' | 'layout'; <nz-resizable nzScene="layout"></nz-resizable>
让我知道你的想法 :) |
我觉得可以直接叫 |
32149be
to
0560b5d
Compare
0560b5d
to
d011a5f
Compare
@@ -93,4 +103,18 @@ export class NzResizeHandleComponent implements OnInit { | |||
}); | |||
}); | |||
} | |||
|
|||
@HostListener('pointerdown') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么我们不用 mousedown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PointerEvent 同时支持 mouse/touch 等多种指针事件
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那也许我们可以试试 Element.setPointerCapture() 这样就不用 getComputedStyle
了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以的,我在 Chrome/Firefox for Mac 下测试,使用 Element.setPointerCapture(),我们甚至不需要为 doc.body 设置 user-select: none
样式,也不再需要 :not(.@{resizable-prefix-cls}-resizing)
条件选择器
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HyperLife1119 这里会导致 nz-resize-handle
中的子组件的 onClick 事件被吞掉,需要多次点击才能触发
https://stackblitz.com/edit/angular-41b5ra?file=src%2Fapp%2Fapp.component.ts
d3145e3
to
4590480
Compare
}, | ||
providers: [NzDestroyService] | ||
}) | ||
export class NzResizeHandleComponent implements OnInit { | ||
@Input() nzDirection: NzResizeDirection = 'bottomRight'; | ||
@Output() readonly nzMouseDown = new EventEmitter<NzResizeHandleMouseDownEvent>(); | ||
|
||
protected readonly resizableDirective = inject(NzResizableDirective); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
由于 nz-resize-handle
和 nz-resize-handles
都是 OnPush 的,只有在它们的 Inputs 发生变化时才会进行变更检测,这将导致 nz-resize-handle
无法响应 [nz-resizable]
指令的 nzCursorType
变更。
一些可能的解决办法:
-
将
nz-resize-handle
和nz-resize-handles
组件调整为ChangeDetectionStrategy.Default
。
我认为这不会引起太大的性能问题,因为它们的父组件([nz-resizable]
)是 OnPush 的,也就是说,它们的变更检测时机将受限于父组件:只有当父组件进行变更检测后,子组件才有机会进行变更检测 -
为
nz-resize-handle
和nz-resize-handles
组件添加nzCurosrType
input,逐层传递 -
使用
ngDoCheck
,在nz-resize-handle
组件内部实现自定义变更检测策略
我更倾向于使用第一种方式或第三种办法,你认为呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Input 放 nz-resize-handle[nzCursorType] 上呢,比如四周用 window 中间用 grid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那这样 nz-resize-handles
就得支持传递 8 个方向的 nzCursorType
了,这可能需要重构 nz-resize-handles[nzDirections]
input 的类型,或新增另一个 input
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改 nzDirections 的类型吧,这样实现也简单点,一路传下去就行了
4590480
to
cb9ba50
Compare
cb9ba50
to
619afa5
Compare
619afa5
to
084109d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information