keep-out-polyfill
Advanced tools
Comparing version 1.2.4 to 1.2.5
{ | ||
"name": "keep-out-polyfill", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"main": "dist/keep-out-polyfill.umd.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/keep-out-polyfill.esm.js", |
@@ -1,83 +0,88 @@ | ||
class KeepOut { | ||
constructor() { | ||
this.winHeight = window.innerHeight; | ||
this.navHeight = screen.availHeight - this.winHeight | ||
this.isKeepOut = null | ||
this.isbodyHide = null | ||
this.keyHeight = 0 | ||
this.clientY = 0 | ||
this.init() | ||
} | ||
init() { | ||
this.initOrientation() | ||
this.initFocus() | ||
this.initBlur() | ||
} | ||
initOrientation() { | ||
window.addEventListener("orientationchange", () => { | ||
(function(){ | ||
class KeepOut { | ||
constructor() { | ||
this.winHeight = window.innerHeight; | ||
this.navHeight = screen.availHeight - this.winHeight | ||
this.getKeiHeight() | ||
}); | ||
} | ||
isResize() { | ||
// 配合keyboard事件使用 | ||
let curHeight = window.innerHeight; | ||
if (Math.abs(curHeight - this.winHeight) > this.navHeight) { | ||
return true | ||
this.isKeepOut = null | ||
this.isbodyHide = null | ||
this.dispatchResize = false | ||
this.keyHeight = 0 | ||
this.clientY = 0 | ||
this.init() | ||
} | ||
return false | ||
} | ||
getKeiHeight () { | ||
if(this.isKeepOut){ | ||
this.keyHeight = screen.availHeight - window.innerHeight - 50 | ||
init() { | ||
this.initOrientation() | ||
this.initFocus() | ||
this.initBlur() | ||
} | ||
} | ||
onceComput () { | ||
if(this.isKeepOut === null){ | ||
this.isKeepOut = this.isResize() | ||
this.getKeiHeight() | ||
initOrientation() { | ||
window.addEventListener("orientationchange", () => { | ||
this.winHeight = window.innerHeight; | ||
this.navHeight = screen.availHeight - this.winHeight | ||
this.dispatchResize = false | ||
}); | ||
} | ||
this.onceComput = function(){} | ||
} | ||
focusFn() { | ||
if(this.isKeepOut === false || this.isbodyHide){ | ||
isResize() { | ||
// 配合keyboard事件使用 | ||
let curHeight = window.innerHeight; | ||
if (Math.abs(curHeight - this.winHeight) > this.navHeight) { | ||
return true | ||
} | ||
return false | ||
} | ||
getKeiHeight () { | ||
if(this.isKeepOut){ | ||
this.keyHeight = screen.availHeight - window.innerHeight - 50 | ||
} | ||
else{ | ||
this.keyHeight = window.innerHeight * 2 / 5 | ||
} | ||
} | ||
onceComput () { | ||
if(this.dispatchResize) return; | ||
this.dispatchResize = true | ||
if(this.isKeepOut === null){ | ||
this.isKeepOut = this.isResize() | ||
this.getKeiHeight() | ||
} | ||
} | ||
focusFn() { | ||
if(this.clientY > this.keyHeight) { | ||
let polyfill = this.clientY - this.keyHeight | ||
document.body.style.transition = '0.2s' | ||
document.body.style.transform = `translateY(-${polyfill}px)` | ||
if(this.isKeepOut === false || this.isbodyHide){ | ||
let polyfill = this.clientY - this.keyHeight | ||
document.body.style.transition = '0.2s' | ||
document.body.style.transform = `translateY(-${polyfill}px)` | ||
} | ||
} | ||
} | ||
} | ||
blurFn() { | ||
if(this.isKeepOut === false || this.isbodyHide){ | ||
blurFn() { | ||
document.body.style.transform = `translateY(0px)` | ||
} | ||
initFocus() { | ||
window.addEventListener('click', (e) => { | ||
let event = e || window.event | ||
this.clientY = event.clientY | ||
}) | ||
window.addEventListener('keyboardFocus', () => { | ||
this.isbodyHide = window.getComputedStyle(document.body, null).getPropertyValue("overflow") === 'hidden' | ||
this.onceComput() | ||
this.focusFn() | ||
}) | ||
} | ||
initBlur() { | ||
window.addEventListener('keyboardBlur', () => { | ||
this.blurFn() | ||
}) | ||
} | ||
} | ||
initFocus() { | ||
window.addEventListener('click', (e) => { | ||
let event = e || window.event | ||
this.clientY = event.clientY | ||
}) | ||
window.addEventListener('keyboardFocus', () => { | ||
this.isbodyHide = window.getComputedStyle(document.body, null).getPropertyValue("overflow") === 'hidden' | ||
this.onceComput() | ||
this.focusFn() | ||
}) | ||
} | ||
initBlur() { | ||
window.addEventListener('keyboardBlur', () => { | ||
this.blurFn() | ||
}) | ||
} | ||
} | ||
new KeepOut() | ||
new KeepOut() | ||
})() |
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
350351
126