File tree 2 files changed +8
-3
lines changed
2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " v-track" ,
3
- "version" : " 0.8.6 " ,
3
+ "version" : " 0.8.7 " ,
4
4
"description" : " 一个基于Vue指令的埋点插件" ,
5
5
"author" : " LHammer <lhammer@qq.com>" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change 2
2
* @Author : 宋慧武
3
3
* @Date : 2019-04-08 11:13:34
4
4
* @Last Modified by: 宋慧武
5
- * @Last Modified time: 2019-04-20 18:34:33
5
+ * @Last Modified time: 2019-08-13 12:14:37
6
6
*/
7
7
import { isElement , isVisible , isInViewport } from "./dom" ;
8
8
import { isFun , debounce } from "./helper" ;
@@ -22,6 +22,7 @@ export default class VisMonitor {
22
22
this . ref = ref ;
23
23
this . refWin = refwin ;
24
24
this . started = false ;
25
+ this . prevPerc = null ; // 保存前一次曝光百分比
25
26
this . listeners = { } ;
26
27
this . removeScrollLisener = null ;
27
28
this . init ( ) ;
@@ -116,6 +117,7 @@ export default class VisMonitor {
116
117
const view = this . viewport ( ) ;
117
118
118
119
if ( ! isInViewport ( rect , view ) || ! isVisible ( this . ele ) ) {
120
+ this . prevPerc = 0 ;
119
121
return 0 ;
120
122
}
121
123
@@ -134,7 +136,10 @@ export default class VisMonitor {
134
136
vw = Math . min ( view . width , rect . right ) ;
135
137
}
136
138
perc = ( vh * vw ) / ( rect . height * rect . width ) ;
137
- if ( perc === 1 ) this . $emit ( "fullyvisible" ) ;
139
+ if ( this . prevPerc !== 1 && perc === 1 ) {
140
+ this . $emit ( "fullyvisible" ) ;
141
+ this . prevPerc = perc ;
142
+ }
138
143
}
139
144
140
145
/**
You can’t perform that action at this time.
0 commit comments