Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 15c2e1f

Browse files
authoredJun 13, 2017
Merge pull request fex-team#3216 from jinzhk/patch-1
修复 autoheight 插件在 destroy 后 onscroll 报错的问题
2 parents d282854 + 5df3d0a commit 15c2e1f

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed
 

‎_src/plugins/autoheight.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ UE.plugins['autoheight'] = function () {
5353
isFullscreen = f
5454
});
5555
me.addListener('destroy', function () {
56+
domUtils.un(me.window, "scroll", fixedScrollTop);
5657
me.removeListener('contentchange afterinserthtml keyup mouseup',adjustHeight)
5758
});
5859
me.enableAutoHeight = function () {
@@ -99,17 +100,20 @@ UE.plugins['autoheight'] = function () {
99100

100101
});
101102
//修复内容过多时,回到顶部,顶部内容被工具栏遮挡问题
102-
var lastScrollY;
103-
window.onscroll = function(){
104-
if(lastScrollY === null){
105-
lastScrollY = this.scrollY
106-
}else if(this.scrollY == 0 && lastScrollY != 0){
107-
me.window.scrollTo(0,0);
108-
lastScrollY = null;
109-
}
110-
}
103+
domUtils.on(me.window, "scroll", fixedScrollTop);
111104
});
112105

106+
var lastScrollY;
107+
108+
function fixedScrollTop() {
109+
if(!me.window) return;
110+
if(lastScrollY === null){
111+
lastScrollY = me.window.scrollY
112+
}else if(me.window.scrollY == 0 && lastScrollY != 0){
113+
me.window.scrollTo(0,0);
114+
lastScrollY = null;
115+
}
116+
}
113117

114118
};
115119

0 commit comments

Comments
 (0)
Please sign in to comment.