vue-scroll-progress
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "vue-scroll-progress", | ||
"description": "Simple Vue.js plugin for page scroll progress bar", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"author": "spemer <ghsspower@naver.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -7,8 +7,6 @@ var VueScrollProgress = { | ||
progressEl, | ||
height, | ||
windowScrollPixels, | ||
windowScrollPercents | ||
windowScrollPercents, | ||
height | ||
// TODO: enable bottom scroll bar | ||
progressContainerEl = document.createElement('div') | ||
@@ -33,5 +31,31 @@ progressContainerEl.id = 'progress-container-el' | ||
windowScrollPercents = 0 | ||
height = (document.documentElement.scrollHeight - | ||
document.documentElement.clientHeight) | ||
function getHeight() { | ||
height = (document.documentElement.scrollHeight - document.documentElement.clientHeight) | ||
} | ||
const debounce = (func, wait, immediate) => { | ||
var timeout | ||
return () => { | ||
const context = this, | ||
args = arguments | ||
const later = function () { | ||
timeout = null | ||
if (!immediate) func.apply(context, args) | ||
} | ||
const callNow = immediate && !timeout | ||
clearTimeout(timeout) | ||
timeout = setTimeout(later, wait) | ||
if (callNow) func.apply(context, args) | ||
} | ||
} | ||
var h = document.body | ||
h.addEventListener('resize', debounce(() => { | ||
getHeight() | ||
console.log(height) | ||
}, 200, false), false) | ||
getHeight() | ||
window.addEventListener('scroll', () => { | ||
@@ -38,0 +62,0 @@ windowScrollPixels = (document.body.scrollTop || |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9571
67