Skip to content

Commit f66e296

Browse files
committed
remove pageheight
1 parent f5b1a1a commit f66e296

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

in-viewport.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import Vue from 'vue';
33
export const inviewport = {
44
inserted: function (el,binding) {
55
//DATA
6-
var pageHeight = null;
76
var elem = null;
87
var viewport = null;
98
var scrollY = null;
@@ -32,7 +31,6 @@ export const inviewport = {
3231
terminal.style.cssText = "position: fixed;top:0;right:0;background-color:#000;color: #fff;width: 300px;height: 300px;z-index: 100;opacity: .8;padding:15px;";
3332
document.body.appendChild(terminal);
3433

35-
3634
var marginTop = document.createElement("div");
3735
marginTop.style.cssText = "position:fixed;height: 1px;width: 100%;background-color: red;left:0;z-index: 50;top:"+viewportTopMargin+"px;";
3836
document.body.appendChild(marginTop);
@@ -48,11 +46,6 @@ export const inviewport = {
4846
}
4947

5048
//FUNCTIONS
51-
var getPageHeight = function(){
52-
var _body = document.body, _html = document.documentElement;
53-
return Math.max( _body.scrollHeight, _body.offsetHeight, _html.clientHeight, _html.scrollHeight, _html.offsetHeight);
54-
};
55-
5649
var getElemClientRect = function(){
5750
return JSON.parse(JSON.stringify(el.getBoundingClientRect()));
5851
};
@@ -120,14 +113,12 @@ export const inviewport = {
120113

121114
//UPDATE FUNCTION
122115
var updatePositions = function(){
123-
pageHeight = getPageHeight();
124116
elem = getElemClientRect();
125117
viewport = getViewportHeight();
126118
scrollY = getScrollY();
127119
elementPos = checkPosition();
128120
if(debugMode){
129121
console.log('--------------------------')
130-
console.log('pageHeight = '+pageHeight);
131122
console.log('elem.top = '+elem.top);
132123
console.log('elem.bottom = '+elem.bottom);
133124
console.log('viewport = '+viewport);
@@ -136,7 +127,6 @@ export const inviewport = {
136127
console.log('viewportBottomMargin = '+viewportBottomMargin);
137128
console.log('elementPos = '+elementPos);
138129
var html = '';
139-
html += 'pageHeight = '+pageHeight+'<br />';
140130
html += 'viewport = '+viewport+'<br />';
141131
html += 'scrollY = '+scrollY+'<br />';
142132
html += 'viewportTopMargin = '+viewportTopMargin+'<br />';

index.html

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</head>
3939
<body>
4040
<div class="app" id='app'>
41-
<div class="item" v-emoji>{{message}}</div>
41+
<div class="item"></div>
4242
<div class="item"></div>
4343
<div class="item"></div>
4444
<div class="item"></div>
@@ -47,7 +47,7 @@
4747
<div class="item"></div>
4848
<div class="item"></div>
4949
<div class="item">
50-
<div class="elem" ref="elem" id="elem" v-in-viewport="{'vMarginTop': 100, 'vMarginBottom': 200, 'debugMode': true, 'once': true}"></div>
50+
<div class="elem" id="elem" v-in-viewport="{'vMarginTop': 100, 'vMarginBottom': 200, 'debugMode': true, 'once': true}"></div>
5151
</div>
5252
<div class="item"></div>
5353
<div class="item"></div>
@@ -62,7 +62,6 @@
6262
'in-viewport':{
6363
inserted: function (el,binding) {
6464
//DATA
65-
var pageHeight = null;
6665
var elem = null;
6766
var viewport = null;
6867
var scrollY = null;
@@ -90,7 +89,6 @@
9089
var terminal = document.createElement("div");
9190
terminal.style.cssText = "position: fixed;top:0;right:0;background-color:#000;color: #fff;width: 300px;height: 300px;z-index: 100;opacity: .8;padding:15px;";
9291
document.body.appendChild(terminal);
93-
9492

9593
var marginTop = document.createElement("div");
9694
marginTop.style.cssText = "position:fixed;height: 1px;width: 100%;background-color: red;left:0;z-index: 50;top:"+viewportTopMargin+"px;";
@@ -107,11 +105,6 @@
107105
}
108106

109107
//FUNCTIONS
110-
var getPageHeight = function(){
111-
var _body = document.body, _html = document.documentElement;
112-
return Math.max( _body.scrollHeight, _body.offsetHeight, _html.clientHeight, _html.scrollHeight, _html.offsetHeight);
113-
};
114-
115108
var getElemClientRect = function(){
116109
return JSON.parse(JSON.stringify(el.getBoundingClientRect()));
117110
};
@@ -179,14 +172,12 @@
179172

180173
//UPDATE FUNCTION
181174
var updatePositions = function(){
182-
pageHeight = getPageHeight();
183175
elem = getElemClientRect();
184176
viewport = getViewportHeight();
185177
scrollY = getScrollY();
186178
elementPos = checkPosition();
187179
if(debugMode){
188180
console.log('--------------------------')
189-
console.log('pageHeight = '+pageHeight);
190181
console.log('elem.top = '+elem.top);
191182
console.log('elem.bottom = '+elem.bottom);
192183
console.log('viewport = '+viewport);
@@ -195,7 +186,6 @@
195186
console.log('viewportBottomMargin = '+viewportBottomMargin);
196187
console.log('elementPos = '+elementPos);
197188
var html = '';
198-
html += 'pageHeight = '+pageHeight+'<br />';
199189
html += 'viewport = '+viewport+'<br />';
200190
html += 'scrollY = '+scrollY+'<br />';
201191
html += 'viewportTopMargin = '+viewportTopMargin+'<br />';

0 commit comments

Comments
 (0)