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
[WIP]: 交互设计 #4208
Labels
Comments
交互发生触发反馈有两种路径:
Action 反馈,本质上也是函数,有明确的通途、输入、输出(只不过输入从 context 获取、输出是操作 context)
弊端: Action 拆分没有标准,有的时候过于细化了 内置 ElementActive// 伪代码
// GetElements action: 出参是 shared.elements
const GetElements = (options: { elements }) => {
return (context) => {
// 这里可以通过任何方式去获取
context.shared.elements = elements || [...]
}
}
// ActiveElement action: 入参是 shared.elements
const ActiveElement = (options: { fill }) => {
return (context) => {
const elements = context.shared.elements;
elements.forEach(ele => ele.style.fill = fill)
}
}
// 注册为 library, 可以通过指定 action type 获取.
const ElementActive = () => {
start: [
{ trigger: 'mouseenter', action: [{ type: 'getElements' }, { type: 'activeElement' }] },
],
end: [
//
{ trigger: 'mouseleave', action: [{ type: 'getElements', elements: [] }, { type: 'activeElement' }] },
]
} 复写 ElementActiveconst CustomGetElements = () => {
return (context) => {
// 监听外部 div 块的激活情况, 获取 id
context.shared.elements = plot.querySelectorAll(`.element#${id}`);
}
}
const CustomElementActive = () => {
start: [
{ trigger: 'mouseenter', action: [{ type: CustomGetElements }, { type: 'activeElement' }] },
],
end: [
//
{ trigger: 'mouseleave', action: [{ type: CustomGetElements }, { type: 'activeElement' }] },
]
} |
转入到 discussion 吧~ |
好 |
转到 Discussions:#4388 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
交互
交互已经根据按照 4.0 以及山大的交互语法实现了一版,但目前还存在一些问题,这里对交互语法进行修改,目的是解决这些问题。
存在问题
开始
这里用高亮交互举例子。
有以下实现方式:
设计
API 形式的设计参考了 RXJS,一种声明形式处理事件的方式。
The text was updated successfully, but these errors were encountered: