-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[scroll-view] call _processDeltaMove()
in update()
#16131
Conversation
call `_processAutoScrolling()` in `update()`
_processAutoScrolling()
in update()
_processDeltaMove()
in update()
Interface Check Report! WARNING this pull request has changed these public interfaces:
@@ -55545,29 +55545,30 @@
protected _topBoundary: number;
protected _bottomBoundary: number;
protected _leftBoundary: number;
protected _rightBoundary: number;
- protected _touchMoveDisplacements: math.Vec3[];
+ protected _touchMoveDisplacements: codec[];
protected _touchMoveTimeDeltas: number[];
protected _touchMovePreviousTimestamp: number;
protected _touchMoved: boolean;
protected _autoScrollAttenuate: boolean;
- protected _autoScrollStartPosition: math.Vec3;
- protected _autoScrollTargetDelta: math.Vec3;
+ protected _autoScrollStartPosition: any;
+ protected _autoScrollTargetDelta: any;
protected _autoScrollTotalTime: number;
protected _autoScrollAccumulatedTime: number;
protected _autoScrollCurrentlyOutOfBoundary: boolean;
protected _autoScrollBraking: boolean;
- protected _autoScrollBrakingStartPosition: math.Vec3;
- protected _outOfBoundaryAmount: math.Vec3;
+ protected _autoScrollBrakingStartPosition: any;
+ protected _outOfBoundaryAmount: any;
protected _outOfBoundaryAmountDirty: boolean;
protected _stopMouseWheel: boolean;
protected _mouseWheelEventElapsedTime: number;
protected _isScrollEndedWithThresholdEventFired: boolean;
protected _scrollEventEmitMask: number;
protected _isBouncing: boolean;
- protected _contentPos: math.Vec3;
- protected _deltaPos: math.Vec3;
+ protected _contentPos: any;
+ protected _deltaPos: any;
+ protected _deltaAmount: any;
protected _hoverIn: __private._cocos_ui_scroll_view__XrhoverType;
/**
* @en
* Scroll the content to the bottom boundary of ScrollView.
@@ -55723,9 +55724,9 @@
* let maxScrollOffset = this.getMaxScrollOffset();
* scrollView.scrollToOffset(new Vec2(maxScrollOffset.x / 2, 0), 0.1);
* ```
*/
- scrollToOffset(offset: math.Vec2, timeInSecond?: number, attenuated?: boolean): void;
+ scrollToOffset(offset: codec, timeInSecond?: number, attenuated?: boolean): void;
/**
* @en
* Get the position of the scrolling view relative to the origin in the upper-left corner of the viewport.
*
@@ -55733,9 +55734,9 @@
* 获取滚动视图相对于视图窗口左上角原点的位置。
*
* @return @en Current rolling offset. @zh 当前滚动偏移量。
*/
- getScrollOffset(): math.Vec2;
+ getScrollOffset(): codec;
/**
* @en
* Get the maximize available scroll offset.
*
@@ -55743,9 +55744,9 @@
* 获取滚动视图最大可以滚动的偏移量。
*
* @return @en Maximum scrollable offset. @zh 最大可滚动偏移量。
*/
- getMaxScrollOffset(): math.Vec2;
+ getMaxScrollOffset(): codec;
/**
* @en
* Scroll the content to the horizontal percent position of ScrollView.
*
@@ -55785,9 +55786,9 @@
* // Horizontal scroll to view right.
* scrollView.scrollTo(new Vec2(1, 0), 0.1);
* ```
*/
- scrollTo(anchor: math.Vec2, timeInSecond?: number, attenuated?: boolean): void;
+ scrollTo(anchor: codec, timeInSecond?: number, attenuated?: boolean): void;
/**
* @en
* Scroll the content to the vertical percent position of ScrollView.
*
@@ -55822,9 +55823,9 @@
*
* @param position @en Current content position. @zh 希望设置内容框体的位置。
* @deprecated Since 3.1.0, setContentPosition is deprecated, please use scrollToOffset instead.
*/
- setContentPosition(position: math.Vec3): void;
+ setContentPosition(position: codec): void;
/**
* @en
* Query the content's position in its parent space.
*
@@ -55833,9 +55834,9 @@
*
* @returns @en current content position. @zh 当前视图内容的坐标点。
* @deprecated Since 3.1.0, getContentPosition is deprecated.
*/
- getContentPosition(): math.Vec3;
+ getContentPosition(): codec;
/**
* @en
* Query whether the user is currently dragging the ScrollView to scroll it.
*
@@ -55872,50 +55873,50 @@
protected _onTouchMoved(event: EventTouch, captureListeners?: Node[]): void;
protected _onTouchEnded(event: EventTouch, captureListeners?: Node[]): void;
protected _onTouchCancelled(event: EventTouch, captureListeners?: Node[]): void;
protected _calculateBoundary(): void;
- protected _hasNestedViewGroup(event: Event, captureListeners?: Node[]): boolean;
- protected _startInertiaScroll(touchMoveVelocity: math.Vec3): void;
+ protected _hasNestedViewGroup(event: codec, captureListeners?: Node[]): boolean;
+ protected _startInertiaScroll(touchMoveVelocity: codec): void;
protected _calculateAttenuatedFactor(distance: number): number;
- protected _startAttenuatingAutoScroll(deltaMove: math.Vec3, initialVelocity: math.Vec3): void;
+ protected _startAttenuatingAutoScroll(deltaMove: codec, initialVelocity: codec): void;
protected _calculateAutoScrollTimeByInitialSpeed(initialSpeed: number): number;
- protected _startAutoScroll(deltaMove: math.Vec3, timeInSecond: number, attenuated?: boolean): void;
- protected _calculateTouchMoveVelocity(): math.Vec3;
- protected _flattenVectorByDirection(vector: math.Vec3): math.Vec3;
- protected _moveContent(deltaMove: math.Vec3, canStartBounceBack?: boolean): void;
+ protected _startAutoScroll(deltaMove: codec, timeInSecond: number, attenuated?: boolean): void;
+ protected _calculateTouchMoveVelocity(): codec;
+ protected _flattenVectorByDirection(vector: codec): codec;
+ protected _moveContent(deltaMove: codec, canStartBounceBack?: boolean): void;
protected _getContentLeftBoundary(): number;
protected _getContentRightBoundary(): number;
protected _getContentTopBoundary(): number;
protected _getContentBottomBoundary(): number;
- protected _getHowMuchOutOfBoundary(addition?: math.Vec3): math.Vec3;
- protected _updateScrollBar(outOfBoundary: math.Vec2 | Readonly<math.Vec2>): void;
+ protected _getHowMuchOutOfBoundary(addition?: codec): codec;
+ protected _updateScrollBar(outOfBoundary: codec | Readonly<codec>): void;
protected _onScrollBarTouchBegan(): void;
protected _onScrollBarTouchEnded(): void;
protected _dispatchEvent(event: string): void;
protected _adjustContentOutOfBoundary(): void;
protected _hideScrollBar(): void;
protected _updateScrollBarState(): void;
- protected _stopPropagationIfTargetIsMe(event: Event): void;
- protected _processDeltaMove(deltaMove: math.Vec3): void;
+ protected _stopPropagationIfTargetIsMe(event: codec): void;
+ protected _processDeltaMove(deltaMove: codec): void;
protected _handleMoveLogic(touch: Touch): void;
protected _handleReleaseLogic(touch: Touch): void;
- protected _getLocalAxisAlignDelta(out: math.Vec3, touch: Touch): void;
- protected _scrollChildren(deltaMove: math.Vec3): void;
+ protected _getLocalAxisAlignDelta(out: codec, touch: Touch): void;
+ protected _scrollChildren(deltaMove: codec): void;
protected _handlePressLogic(): void;
- protected _clampDelta(out: math.Vec3): void;
- protected _gatherTouchMove(delta: math.Vec3): void;
+ protected _clampDelta(out: codec): void;
+ protected _gatherTouchMove(delta: codec): void;
protected _startBounceBackIfNeeded(): boolean;
protected _processInertiaScroll(): void;
protected _isOutOfBoundary(): boolean;
protected _isNecessaryAutoScrollBrake(): boolean;
protected _processAutoScrolling(dt: any): void;
protected _checkMouseWheel(dt: number): void;
- protected _calculateMovePercentDelta(options: any): math.Vec3;
- protected _moveContentToTopLeft(scrollViewSize: math.Size): void;
+ protected _calculateMovePercentDelta(options: any): codec;
+ protected _moveContentToTopLeft(scrollViewSize: codec): void;
protected _scaleChanged(value: TransformBit): void;
protected _xrHoverEnter(event: XrUIPressEvent): void;
protected _xrHoverExit(event: XrUIPressEvent): void;
- protected _xrThumbStickMove(event: math.Vec2): void;
+ protected _xrThumbStickMove(event: codec): void;
}
/**
* @en
* The Slider Control.
@@ -69804,8 +69805,16 @@
*/
export enum _cocos_ui_scroll_view__EventType {
/**
* @en
+ * It means an invalid event type or "default empty value" of EventType.
+ *
+ * @zh
+ * 代表无效事件, 或者EventType的默认空值。
+ */
+ NONE = "",
+ /**
+ * @en
* The event emitted when ScrollView scroll to the top boundary of inner container.
*
* @zh
* 滚动视图滚动到顶部边界事件。
@@ -70400,6 +70409,7 @@
import { AnimationMask, __private as ___private } from "cc/editor/new-gen-anim";
import { CCON, TypedArrayData } from "cc/editor/serialization";
export { Canvas as CanvasComponent, UIRenderer as RenderComponent, UIRenderer as UIRenderable, UIRenderer as Renderable2D, UITransform as UITransformComponent, Mask as MaskComponent, RichText as RichTextComponent, Sprite as SpriteComponent, UIMeshRenderer as UIModelComponent, LabelOutline as LabelOutlineComponent, Graphics as GraphicsComponent, UIOpacity as UIOpacityComponent, Label as LabelComponent, MeshRenderer as ModelComponent, DirectionalLight as DirectionalLightComponent, Light as LightComponent, SphereLight as SphereLightComponent, SpotLight as SpotLightComponent, SkinnedMeshRenderer as SkinningModelComponent, SkinnedMeshBatchRenderer as BatchedSkinningModelComponent, SkinnedMeshUnit as SkinningModelUnit, Animation as AnimationComponent, AudioSource as AudioSourceComponent, Node as BaseNode, Camera as CameraComponent, ModelRenderer as RenderableComponent, Billboard as BillboardComponent, Line as LineComponent, ParticleSystem as ParticleSystemComponent, SkeletalAnimation as SkeletalAnimationComponent, Button as ButtonComponent, EditBox as EditBoxComponent, Layout as LayoutComponent, ProgressBar as ProgressBarComponent, ScrollBar as ScrollBarComponent, ScrollView as ScrollViewComponent, Slider as SliderComponent, Toggle as ToggleComponent, ToggleContainer as ToggleContainerComponent, Widget as WidgetComponent, PageView as PageViewComponent, PageViewIndicator as PageViewIndicatorComponent, SafeArea as SafeAreaComponent, UICoordinateTracker as UICoordinateTrackerComponent, BlockInputEvents as BlockInputEventsComponent } from "cc";
import { Details as _Details } from "cc";
+ import { codec } from "cc/editor/particle-system-2d-utils";
export {};
}
|
For #15390 |
优化格式 , 使其更符合eslint的要求
修正格式错误
添加注释.
cocos/ui/scroll-view.ts
Outdated
@@ -1406,7 +1444,7 @@ export class ScrollView extends ViewGroup { | |||
} | |||
} | |||
|
|||
protected _dispatchEvent (event: string): void { | |||
protected _dispatchEvent (event: EventType): void { |
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.
It is not recommended to use EventType here, because event may also be the value in eventMap is of type string.
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.
It is not recommended to use EventType here, because event may also be the value in eventMap is of type string.
已改
cocos/ui/scroll-view.ts
Outdated
@@ -1487,7 +1525,8 @@ export class ScrollView extends ViewGroup { | |||
|
|||
protected _handleMoveLogic (touch: Touch): void { | |||
this._getLocalAxisAlignDelta(this._deltaPos, touch); | |||
this._processDeltaMove(this._deltaPos); | |||
this._deltaAmount.add(this._deltaPos); | |||
// this._processDeltaMove(this._deltaPos); |
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.
It can be removed.
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.
It can be removed.
我的个人习惯: 通过注释 保留改变之前的老代码. 这样便于后面跟踪bug 和了解之前是什么模样.
从实际经验来看, 这种通过注释保留之前代码的方式 比查看git历史要快捷. 等功能测试没有问题 且上线一段时间之后, 再清理这种多余注释.
其实cocos目前的代码. 也有很多类似的注释.
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.
可以通过注释的方式描述下,不建议直接保留这种方式,这样对后面维护的人也很困惑。以后要清理基本上没有表示标识,很容易导致这种东西成为历史遗留。
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.
可以通过注释的方式描述下,不建议直接保留这种方式,这样对后面维护的人也很困惑。以后要清理基本上没有表示标识,很容易导致这种东西成为历史遗留。
已改 .删除了多余注释
deltaAmount.y = 0; | ||
} else if (deltaAmount.x !== 0 || deltaAmount.y !== 0) { | ||
this._processDeltaMove(deltaAmount); | ||
deltaAmount.x = 0; |
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.
Maybe use 'this._deltaAmount.set(0, 0)'?
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.
Maybe use 'this._deltaAmount.set(0, 0)'?
没必要吧, 测试过, 直接修改x y更快.
我在 onDisable 里用了 set(0,0), 因为对性能不敏感. 但是 update还是有点敏感.
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.
这种敏感程度感觉可以忽略吧,这种影响基本上感觉微乎其微了。
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.
这种敏感程度感觉可以忽略吧,这种影响基本上感觉微乎其微了。
cocos发展到今天, 重大的性能瓶颈已经没有了. 剩下的就是分散在很多地方的 '微乎其微'的小问题了.
我的原则是没必要主动的 故意的去查找和修改这些小问题, 但是如果恰巧遇到了, 那么能优化一个是一个.
这个问题属于理念之争, 无所谓对错. 没必要深入讨论.
我是不打算改. 如果因为这个问题, cocos拒绝合并此pr, 那我也没办法....
使用 string类型的event参数
移出多余的注释
麻烦帮忙修复下冲突哈? |
已经尝试解决.不过是在在线web编辑器里解决的, 没测试... |
好像ci没过,能够帮忙看看么? |
我看了下错误, 和我写的代码关系不大 . 一部分是eslint的. 一部分是引用的其他的文件出的错. 我在 3.8.2分支上重新提交了一次 |
call
_processDeltaMove()
inupdate()
it should not call run _processDeltaMove() in every touchmove event , it will take bad performance.
Re: #
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request: