提交 062fc810 编写于 作者: Q qiang

feat(App): onWindowResize, offWindowResize

上级 25cea862
......@@ -13,6 +13,7 @@ export * from './service/ui/createMediaQueryObserver'
export * from './service/ui/createSelectorQuery'
export * from './service/ui/createAnimation'
export * from './service/ui/tabBar'
export * from './service/ui/window'
export * from './service/keyboard/getSelectedTextRange'
......@@ -84,7 +85,6 @@ export * from './protocols/ui/showToast'
export * from './protocols/ui/startPullDownRefresh'
export * from './protocols/ui/stopPullDownRefresh'
export * from './protocols/ui/tabBar'
export * from './protocols/ui/window'
export * from './protocols/plugin/getProvider'
export * from './protocols/plugin/oauth'
......
import {
API_ON_WINDOW_RESIZE,
API_TYPE_ON_WINDOW_RESIZE,
API_OFF_WINDOW_RESIZE,
API_TYPE_OFF_WINDOW_RESIZE,
} from '../../protocols/ui/window'
import { defineOnApi, defineOffApi } from '../../helpers/api'
/**
* 监听窗口大小变化
*/
export const onWindowResize = defineOnApi<API_TYPE_ON_WINDOW_RESIZE>(
API_ON_WINDOW_RESIZE,
() => {
// 生命周期包括onResize,框架直接监听resize
// window.addEventListener('resize', onResize)
}
)
/**
* 取消监听窗口大小变化
*/
export const offWindowResize = defineOffApi<API_TYPE_OFF_WINDOW_RESIZE>(
API_OFF_WINDOW_RESIZE,
() => {
// window.removeEventListener('resize', onResize)
}
)
......@@ -3937,6 +3937,23 @@ var serviceContext = (function (vue) {
// noop
});
const API_ON_WINDOW_RESIZE = 'onWindowResize';
const API_OFF_WINDOW_RESIZE = 'offWindowResize';
/**
* 监听窗口大小变化
*/
const onWindowResize = defineOnApi(API_ON_WINDOW_RESIZE, () => {
// 生命周期包括onResize,框架直接监听resize
// window.addEventListener('resize', onResize)
});
/**
* 取消监听窗口大小变化
*/
const offWindowResize = defineOffApi(API_OFF_WINDOW_RESIZE, () => {
// window.removeEventListener('resize', onResize)
});
const API_GET_SELECTED_TEXT_RANGE = 'getSelectedTextRange';
const getSelectedTextRange = defineAsyncApi(API_GET_SELECTED_TEXT_RANGE, (_, { resolve, reject }) => {
......@@ -10715,6 +10732,8 @@ var serviceContext = (function (vue) {
createVideoContext: createVideoContext,
createMapContext: createMapContext,
createAnimation: createAnimation,
onWindowResize: onWindowResize,
offWindowResize: offWindowResize,
onTabBarMidButtonTap: onTabBarMidButtonTap,
createCanvasContext: createCanvasContext,
canvasGetImageData: canvasGetImageData,
......
......@@ -77,6 +77,8 @@ export {
createVideoContext,
createMapContext,
createAnimation,
onWindowResize,
offWindowResize,
onTabBarMidButtonTap,
createCanvasContext,
canvasGetImageData,
......
......@@ -4403,6 +4403,12 @@ const createAnimation$1 = /* @__PURE__ */ defineSyncApi(API_CREATE_ANIMATION, (o
const API_ON_TAB_BAR_MID_BUTTON_TAP = "onTabBarMidButtonTap";
const onTabBarMidButtonTap = /* @__PURE__ */ defineOnApi(API_ON_TAB_BAR_MID_BUTTON_TAP, () => {
});
const API_ON_WINDOW_RESIZE = "onWindowResize";
const API_OFF_WINDOW_RESIZE = "offWindowResize";
const onWindowResize = /* @__PURE__ */ defineOnApi(API_ON_WINDOW_RESIZE, () => {
});
const offWindowResize = /* @__PURE__ */ defineOffApi(API_OFF_WINDOW_RESIZE, () => {
});
const API_GET_SELECTED_TEXT_RANGE = "getSelectedTextRange";
const getSelectedTextRange$1 = /* @__PURE__ */ defineAsyncApi(API_GET_SELECTED_TEXT_RANGE, (_, { resolve, reject }) => {
UniServiceJSBridge.invokeViewMethod("getSelectedTextRange", {}, getCurrentPageId(), (res) => {
......@@ -5263,8 +5269,6 @@ const SetTabBarBadgeOptions = {
}
}, IndexOptions.formatArgs)
};
const API_ON_WINDOW_RESIZE = "onWindowResize";
const API_OFF_WINDOW_RESIZE = "offWindowResize";
const initIntersectionObserverPolyfill = function() {
if (typeof window !== "object") {
return;
......@@ -18990,10 +18994,6 @@ function createRightWindowTsx(rightWindow, layoutState, windowState) {
}, 8, ["data-show", "style"]), [[vShow, layoutState.showRightWindow || layoutState.apiShowRightWindow]]);
}
}
const onWindowResize = /* @__PURE__ */ defineOnApi(API_ON_WINDOW_RESIZE, () => {
});
const offWindowResize = /* @__PURE__ */ defineOffApi(API_OFF_WINDOW_RESIZE, () => {
});
const showTopWindow = /* @__PURE__ */ defineAsyncApi("showTopWindow", (_, { resolve, reject }) => {
const state2 = getLayoutState();
if (!state2) {
......@@ -19133,6 +19133,8 @@ var api = {
createVideoContext,
createMapContext,
createAnimation: createAnimation$1,
onWindowResize,
offWindowResize,
onTabBarMidButtonTap,
createCanvasContext,
canvasGetImageData,
......@@ -19225,8 +19227,6 @@ var api = {
showTabBarRedDot,
removeTabBarBadge,
setTabBarBadge,
onWindowResize,
offWindowResize,
showTopWindow,
hideTopWindow,
showLeftWindow,
......
......@@ -77,6 +77,8 @@ export {
createVideoContext,
createMapContext,
createAnimation,
onWindowResize,
offWindowResize,
onTabBarMidButtonTap,
createCanvasContext,
canvasGetImageData,
......
import { extend } from '@vue/shared'
import { nextTick } from 'vue'
import {
API_ON_WINDOW_RESIZE,
API_TYPE_ON_WINDOW_RESIZE,
API_OFF_WINDOW_RESIZE,
API_TYPE_OFF_WINDOW_RESIZE,
defineOnApi,
defineOffApi,
defineAsyncApi,
defineSyncApi,
} from '@dcloudio/uni-api'
import { defineAsyncApi, defineSyncApi } from '@dcloudio/uni-api'
import { getLayoutState } from '../../../framework/components/layout'
/**
* 监听窗口大小变化
*/
export const onWindowResize = defineOnApi<API_TYPE_ON_WINDOW_RESIZE>(
API_ON_WINDOW_RESIZE,
() => {
// 生命周期包括onResize,框架直接监听resize
// window.addEventListener('resize', onResize)
}
)
/**
* 取消监听窗口大小变化
*/
export const offWindowResize = defineOffApi<API_TYPE_OFF_WINDOW_RESIZE>(
API_OFF_WINDOW_RESIZE,
() => {
// window.removeEventListener('resize', onResize)
}
)
export const showTopWindow = <typeof uni.showTopWindow>(
defineAsyncApi('showTopWindow', (_, { resolve, reject }) => {
const state = getLayoutState()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册