If using the new style context, re-declare this in your class to be the
React.ContextType
of your static contextType
.
Should be used with type annotation or static contextType.
static contextType = MyContext
// For TS pre-3.7:
context!: React.ContextType<typeof MyContext>
// For TS 3.7 and above:
declare context: React.ContextType<typeof MyContext>
临时用来记录哪些按键和ctrl一起被按下了的状态。 注意,这个属性不使用state来处理,因为 1)这是一个临时属性,只在ctrl按下时生效, 2)这个属性不影响render,只影响对外提供的操作函数,本质上是操作函数之中的一个变量。 3)这个属性要求其修改即时响应。 XXX 但是我也不知道这样实现是不是合理的....
记录每个空间中有的元素。
If set, this.context
will be set at runtime to the current value of the given Context.
Usage:
type MyContext = number
const Ctx = React.createContext<MyContext>(0)
class Foo extends React.Component {
static contextType = Ctx
context!: React.ContextType<typeof Ctx>
render () {
return <>My context's value: {this.context}</>;
}
}
Called immediately before mounting occurs, and before Component#render
.
Avoid introducing any side-effects or subscriptions in this method.
This method will not stop working in React 17.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
Called when the component may be receiving new props. React may call this even if props have not changed, so be sure to compare new and existing props if you only want to handle changes.
Calling Component#setState
generally does not trigger this method.
This method will not stop working in React 17.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
Called immediately before rendering when new props or state is received. Not called for the initial render.
Note: You cannot call Component#setState
here.
This method will not stop working in React 17.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
新激活一个位置。 注意,这个函数通常不需要调用,因为会在当前激活元素切换时在componentDidUpdate中自动调用。
激活一个位置,并自动修改cur_position
状态,并取消激活之前的位置。
Catches exceptions generated in descendant components. Unhandled exceptions will cause the entire component tree to unmount.
Called immediately after a component is mounted. Setting state here will trigger re-rendering.
Called immediately after updating occurs. Not called for the initial render.
The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.
Called immediately before mounting occurs, and before Component#render
.
Avoid introducing any side-effects or subscriptions in this method.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
Called when the component may be receiving new props. React may call this even if props have not changed, so be sure to compare new and existing props if you only want to handle changes.
Calling Component#setState
generally does not trigger this method.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as
cancelled network requests, or cleaning up any DOM elements created in componentDidMount
.
Called immediately before rendering when new props or state is received. Not called for the initial render.
Note: You cannot call Component#setState
here.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
目前ctrl键是否处于按下状态。
一个处理鼠标事件的代理函数会处理三种情况:没有按下ctrl因此什么也不做、激活了某一个空间或者非空间操作、在某个空间激活的情况下进行移动。 并且在执行了对应操作的情况下阻止事件传播。 这个函数在这三种情况下都什么也不做,只是阻止事件传播。
是否被本管理器处理。返回true
表示本管理器(不一定是这个函数)会处理此事件。
给定一个新的按键事件,设置自己的ctrl_key
状态。
Runs before React applies the result of render
to the document, and
returns an object to be given to componentDidUpdate. Useful for saving
things such as scroll position before render
causes changes to it.
Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated lifecycle events from running.
查询当前哪个空间正在被激活。
获得一个空间的位置。
获取一个空间内的所有元素位置。
获取一个具体的元素的操作函数。
这个函数代理按键按下事件。 一个处理鼠标事件的代理函数会处理三种情况:没有按下ctrl因此什么也不做、激活了某一个空间或者非空间操作、在某个空间激活的情况下进行移动。 并且在执行了对应操作的情况下阻止事件传播。
这个函数处理激活某个空间和激活某个非空间操作的的事件,而在最后一种情况下什么也不做。
是否被本管理器处理。返回true
表示本管理器(不一定是这个函数)会处理此事件。
这个函数代理按键抬起事件。 一个处理鼠标事件的代理函数会处理三种情况:没有按下ctrl因此什么也不做、激活了某一个空间或者非空间操作、在某个空间激活的情况下进行移动。 并且在执行了对应操作的情况下阻止事件传播。
这个函数在激活了某一个空间或者非空间操作的情况下都什么也不做(只阻止事件传播),而只处理方向键和回车键的事件。
是否被本管理器处理。返回true
表示本管理器(不一定是这个函数)会处理此事件。
注册一个空间
调用一个位置。
设置一个空间的位置。
Called to determine whether the change in props and state should trigger a re-render.
Component
always returns true.
PureComponent
implements a shallow comparison on props and state and returns true if any
props or states have changed.
If false is returned, Component#render
, componentWillUpdate
and componentDidUpdate
will not be called.
取消激活一个位置。 注意,这个函数通常不需要调用,因为会在当前激活元素切换时在componentDidUpdate中自动调用。
取消一个空间。
这个函数从props
整理出自身的spaces
和non_space_oprations
属性。
Generated using TypeDoc
按键事件管理器。