!9573 uiobserver添加scrollEvent-API调整

Merge pull request !9573 from 徐钦锋/uiobserverAPI
This commit is contained in:
openharmony_ci 2024-03-08 01:34:02 +00:00 committed by Gitee
commit 800bc4d812
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 184 additions and 0 deletions

View File

@ -1016,6 +1016,54 @@ export class UIObserver {
*/
off(type: 'navDestinationUpdate', callback?: Callback<observer.NavDestinationInfo>): void;
/**
* Registers a callback function to be called when the scroll event start or stop.
*
* @param { 'scrollEvent' } type - The type of event to listen for. Must be 'scrollEvent'.
* @param { observer.ObserverOptions } options - The options object.
* @param { Callback<observer.ScrollEventInfo> } callback - The callback function to be called when the scroll event start or stop.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
on(type: 'scrollEvent', options: observer.ObserverOptions, callback: Callback<observer.ScrollEventInfo>): void;
/**
* Removes a callback function that was previously registered with `on()`.
*
* @param { 'scrollEvent' } type - The type of event to remove the listener for. Must be 'scrollEvent'.
* @param { observer.ObserverOptions } options - The options object.
* @param { Callback<observer.ScrollEventInfo> } callback - The callback function to remove. If not provided, all callbacks for the given event type and
* scroll ID will be removed.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
off(type: 'scrollEvent', options: observer.ObserverOptions, callback?: Callback<observer.ScrollEventInfo>): void;
/**
* Registers a callback function to be called when the scroll event start or stop.
*
* @param { 'scrollEvent' } type - The type of event to listen for. Must be 'scrollEvent'.
* @param { Callback<observer.ScrollEventInfo> } callback - The callback function to be called when the scroll event start or stop.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
on(type: 'scrollEvent', callback: Callback<observer.ScrollEventInfo>): void;
/**
* Removes a callback function that was previously registered with `on()`.
*
* @param { 'scrollEvent'} type - The type of event to remove the listener for. Must be 'scrollEvent'.
* @param { Callback<observer.ScrollEventInfo> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type
* will be removed.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
off(type: 'scrollEvent', callback?: Callback<observer.ScrollEventInfo>): void;
/**
* Registers a callback function to be called when the router page in a ui context is updated.
*

View File

@ -116,6 +116,34 @@ declare namespace uiObserver {
ON_BACK_PRESS = 4
}
/**
* ScrollEvent type.
*
* @enum { number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
export enum ScrollEventType {
/**
* When the ScrollEvent start.
*
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
SCROLL_START = 0,
/**
* When the ScrollEvent stop.
*
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
SCROLL_STOP = 1
}
/**
* NavDestination info.
*
@ -156,6 +184,66 @@ declare namespace uiObserver {
state: NavDestinationState
}
/**
* ScrollEvent info.
*
* @interface ScrollEventInfo
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
export interface ScrollEventInfo {
/**
* Scroll id.
*
* @type { string }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
id: string,
/**
* Changed ScrollEvent type.
*
* @type { ScrollEventType }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
scrollEvent: ScrollEventType,
/**
* Changed ScrollEvent offset.
*
* @type { number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
offset: number
}
/**
* observer options.
*
* @interface ObserverOptions
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
export interface ObserverOptions {
/**
* component id.
*
* @type { string }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
id: string
}
/**
* Router page info.
*
@ -292,6 +380,54 @@ declare namespace uiObserver {
*/
export function off(type: 'navDestinationUpdate', callback?: Callback<NavDestinationInfo>): void;
/**
* Registers a callback function to be called when the scroll event start or stop.
*
* @param { 'scrollEvent' } type - The type of event to listen for. Must be 'scrollEvent'.
* @param { ObserverOptions } options - The options object.
* @param { Callback<ScrollEventInfo> } callback - The callback function to be called when the scroll event start or stop.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
export function on(type: 'scrollEvent', options: ObserverOptions, callback: Callback<ScrollEventInfo>): void;
/**
* Removes a callback function that was previously registered with `on()`.
*
* @param { 'scrollEvent' } type - The type of event to remove the listener for. Must be 'scrollEvent'.
* @param { ObserverOptions } options - The options object.
* @param { Callback<ScrollEventInfo> } callback - The callback function to remove. If not provided, all callbacks for the given event type and
* scroll ID will be removed.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
export function off(type: 'scrollEvent', options: ObserverOptions, callback?: Callback<ScrollEventInfo>): void;
/**
* Registers a callback function to be called when the scroll event start or stop.
*
* @param { 'scrollEvent' } type - The type of event to listen for. Must be 'scrollEvent'.
* @param { Callback<ScrollEventInfo> } callback - The callback function to be called when the scroll event start or stop.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
export function on(type: 'scrollEvent', callback: Callback<ScrollEventInfo>): void;
/**
* Removes a callback function that was previously registered with `on()`.
*
* @param { 'scrollEvent'} type - The type of event to remove the listener for. Must be 'scrollEvent'.
* @param { Callback<ScrollEventInfo> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type
* will be removed.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
export function off(type: 'scrollEvent', callback?: Callback<ScrollEventInfo>): void;
/**
* Registers a callback function to be called when the router page is updated.
*