This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
1.0.5 #37
Open
SR2k
wants to merge
6
commits into
ant-mini-program:master
Choose a base branch
from
SR2k:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
1.0.5 #37
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ec72bd7
Merge remote-tracking branch 'ant/master'
SR2k da9730c
feat: 更换 ComponentOptions 为 interface
SR2k 8bad442
feat: 增加 intersection observer
SR2k 9b1c850
build: bump 1.0.5
SR2k 0478da5
fix: ci linter 问题修复
SR2k 9f79f88
feat: 加 ComponentOptions 的 deprecated 注释
SR2k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* @file IntersectionObserver 对象,用于推断某些节点是否可以被用户看见、有多大比例可以被用户看见。 | ||
*/ | ||
declare namespace my { | ||
namespace intersectionObserver { | ||
interface ICreateOptions { | ||
/** | ||
* 一个数值数组,包含所有阈值 | ||
*/ | ||
thresholds?: number[]; | ||
|
||
/** | ||
* 初始的相交比例,如果调用时检测到的相交比例与这个值不相等且达到阈值,则会触发一次监听器的回调函数 | ||
*/ | ||
initialRatio?: number; | ||
|
||
/** | ||
* 是否同时观测多个目标节点(而非一个),如果设为 `true` ,observe 的 targetSelector 将选中多个节点(注意:同时选中过多节点将影响渲染性能) | ||
*/ | ||
selectAll?: boolean; | ||
} | ||
|
||
interface IRect { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IRect -> IIntersectionObserverRect |
||
/** | ||
* 左边界 | ||
*/ | ||
left: number; | ||
|
||
/** | ||
* 右边界 | ||
*/ | ||
right: number; | ||
|
||
/** | ||
* 上边界 | ||
*/ | ||
top: number; | ||
|
||
/** | ||
* 下边界 | ||
*/ | ||
bottom: number; | ||
} | ||
|
||
interface IObserveResult { | ||
/** | ||
* 相交比例 | ||
*/ | ||
intersectionRatio: number; | ||
|
||
/** | ||
* 相交区域的边界 | ||
*/ | ||
intersectionRect: IRect; | ||
|
||
/** | ||
* 目标边界 | ||
*/ | ||
boundingClientRect: IRect; | ||
|
||
/** | ||
* 参照区域的边界 | ||
*/ | ||
relativeRect: IRect; | ||
|
||
/** | ||
* 相交检测时的时间戳 | ||
*/ | ||
time: number; | ||
} | ||
|
||
interface IIntersectionObserverInstance { | ||
/** | ||
* 指定页面显示区域作为参照区域之一 | ||
*/ | ||
relativeToViewport(margins?: Partial<IRect>): IIntersectionObserverInstance; | ||
|
||
/** | ||
* 使用选择器指定一个节点,作为参照区域之一 | ||
*/ | ||
relativeTo(selector: string, margins?: Partial<IRect>): IIntersectionObserverInstance; | ||
|
||
/** | ||
* 指定目标节点,并开始监听相交状态变化情况 | ||
*/ | ||
observe( | ||
targetSelector: string, | ||
callback: (res: IObserveResult) => any, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 返回值要不用 void? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 有的时候就用箭头函数的,感觉用 void 会限制这个地方? my.createIntersectionObserver()
.relativeToViewport()
.observe('.className', node => this.nodes.push(node)) // <- 用 void 会报错 |
||
): IIntersectionObserverInstance; | ||
|
||
/** | ||
* 停止监听回调函数将不再触发 | ||
*/ | ||
disconnect(): void; | ||
} | ||
} | ||
|
||
/** | ||
* 获取一个相交监测对象 IntersectionObserver | ||
*/ | ||
function createIntersectionObserver( | ||
options?: intersectionObserver.ICreateOptions, | ||
): intersectionObserver.IIntersectionObserverInstance; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,31 +69,32 @@ declare namespace tinyapp { | |
$spliceData: SpliceDataMethod; | ||
} | ||
|
||
type ComponentOptions< | ||
interface InternalComponentOptions<P, D, M> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
/** | ||
* 组件间代码复用机制 | ||
*/ | ||
mixins?: Array<ComponentOptions<any, any, any>>; | ||
|
||
/** | ||
* 组件内部状态 | ||
*/ | ||
data?: D; | ||
|
||
/** | ||
* 为外部传入的数据设置默认值 | ||
*/ | ||
props?: P; | ||
|
||
/** | ||
* 组件的方法,可以是事件响应函数或任意的自定义方法 | ||
*/ | ||
methods?: M & ThisType<IComponentInstance<P, D> & M>; | ||
} | ||
|
||
interface ComponentOptions< | ||
P extends Record<string, any> = Record<string, any>, | ||
D = any, | ||
M extends IComponentMethods = IComponentMethods, | ||
> = IComponentLifeCycleMethods<D, P> | ||
& { | ||
/** | ||
* 组件间代码复用机制 | ||
*/ | ||
mixins?: Array<ComponentOptions<any, any, any>>; | ||
|
||
/** | ||
* 组件内部状态 | ||
*/ | ||
data?: D; | ||
|
||
/** | ||
* 为外部传入的数据设置默认值 | ||
*/ | ||
props?: P; | ||
|
||
/** | ||
* 组件的方法,可以是事件响应函数或任意的自定义方法 | ||
*/ | ||
methods?: M & ThisType<IComponentInstance<P, D> & M>; | ||
} | ||
& ThisType<IComponentInstance<P, D> & M>; | ||
> extends IComponentLifeCycleMethods<D, P>, InternalComponentOptions<P, D, M>, ThisType<IComponentInstance<P, D> & M> { | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
不需要加这个 namespace 吧