Skip to content

Commit

Permalink
⚡amend modifer click to trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
宋慧武 committed Jul 17, 2019
1 parent 0a30711 commit 63ca878
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/store-mobx/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Created Date: 2019-07-13
* Author: 宋慧武
* ------
* Last Modified: Monday 2019-07-15 16:57:44 pm
* Last Modified: Wednesday 2019-07-17 11:35:35 am
* Modified By: the developer formerly known as 宋慧武 at <[email protected]>
* ------
* HISTORY:
Expand All @@ -24,7 +24,7 @@ class App {
@observable content = null;

@action.bound
@track("click.after", 22121)
@track("trigger.after", 22121)
handleClick(val, e) {
console.log("handleClick 方法正常执行。并受到参数:", val, e.target);
this.date = Date.now();
Expand Down
4 changes: 2 additions & 2 deletions docs/views/home-redux/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Created Date: 2019-07-14
* Author: 宋慧武
* ------
* Last Modified: Tuesday 2019-07-16 11:07:38 am
* Last Modified: Wednesday 2019-07-17 11:34:06 am
* Modified By: the developer formerly known as 宋慧武 at <[email protected]>
* ------
* HISTORY:
Expand Down Expand Up @@ -37,7 +37,7 @@ class Home extends Component {
};
}

@track("click.after", 22121)
@track("trigger.after", 22121)
handleClick(val, e) {
console.log("handleClick 方法正常执行。并受到参数:", val, e.target);
this.setState({
Expand Down
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Created Date: 2019-07-08
* Author: 宋慧武
* ------
* Last Modified: Tuesday 2019-07-16 11:10:24 am
* Last Modified: Wednesday 2019-07-17 11:33:12 am
* Modified By: the developer formerly known as 宋慧武 at <[email protected]>
* ------
* HISTORY:
Expand All @@ -22,8 +22,8 @@ const ONCE = "once";
const modifiers = {
UVPV: "UVPV", // 特殊的修饰符
TONP: "TONP", // 特殊的修饰符,表示页面停留时长
CLICK: "click",
CLICK_AFTER: "click.after",
TRIGGER: "trigger",
TRIGGER_AFTER: "trigger.after",
ASYNC: "async",
ASYNC_DELAY: "async.delay"
};
Expand Down Expand Up @@ -107,14 +107,14 @@ export function track(modifier, eventId, params = {}) {
};
}
// 事件行为埋点
else if (modifier.includes(modifiers.CLICK)) {
else if (modifier.includes(modifiers.TRIGGER)) {
handler = function(...args) {
let context = this;
const isRC = this.isReactComponent; // 是否为 react 组件
const evts = this.trackEvents || this.props.trackEvents;
const once = modifier.includes(ONCE);
const onceProp = `${name}_${eventId}`;
const after = modifier.includes(modifiers.CLICK_AFTER);
const after = modifier.includes(modifiers.TRIGGER_AFTER);
const tck = () => {
if (this[onceProp]) return; // 如果存在once修饰符,且为true则直接返回
vaildEvent(evts, eventId); // 检测eventId是否合法
Expand Down

0 comments on commit 63ca878

Please sign in to comment.