hiding-header
Advanced tools
Comparing version 0.8.4 to 0.9.0
@@ -19,2 +19,3 @@ export interface HidingHeaderOptions { | ||
getVisibleHeight: () => number; | ||
destroy: () => void; | ||
}; |
@@ -114,2 +114,3 @@ function hidingHeader(container, _a) { | ||
}; | ||
// @TODO: remove listeners on destroy() | ||
content.addEventListener('transitionstart', function () { | ||
@@ -119,2 +120,3 @@ running = true; | ||
}); | ||
// @TODO: remove listeners on destroy() | ||
content.addEventListener('transitionend', function () { | ||
@@ -155,15 +157,23 @@ running = false; | ||
var onResize = onScroll; | ||
document.addEventListener('pointerdown', function () { | ||
var onPointerDown = function () { | ||
pointersDown++; | ||
onScroll(); | ||
}); | ||
document.addEventListener('pointerup', function () { | ||
}; | ||
var onPointerUp = function () { | ||
pointersDown--; | ||
onScroll(); | ||
}); | ||
}; | ||
var initialize = function () { | ||
window.addEventListener('scroll', onScroll); | ||
window.addEventListener('resize', onResize); | ||
document.addEventListener('pointerdown', onPointerDown); | ||
document.addEventListener('pointerup', onPointerUp); | ||
onScroll(); | ||
}; | ||
var destroy = function () { | ||
window.removeEventListener('scroll', onScroll); | ||
window.removeEventListener('resize', onResize); | ||
document.removeEventListener('pointerdown', onPointerDown); | ||
document.removeEventListener('pointerup', onPointerUp); | ||
}; | ||
initialize(); | ||
@@ -205,2 +215,3 @@ var run = function () { | ||
getVisibleHeight: getVisibleHeight, | ||
destroy: destroy, | ||
}; | ||
@@ -210,2 +221,1 @@ } | ||
export { hidingHeader }; | ||
//# sourceMappingURL=index.es.js.map |
@@ -118,2 +118,3 @@ 'use strict'; | ||
}; | ||
// @TODO: remove listeners on destroy() | ||
content.addEventListener('transitionstart', function () { | ||
@@ -123,2 +124,3 @@ running = true; | ||
}); | ||
// @TODO: remove listeners on destroy() | ||
content.addEventListener('transitionend', function () { | ||
@@ -159,15 +161,23 @@ running = false; | ||
var onResize = onScroll; | ||
document.addEventListener('pointerdown', function () { | ||
var onPointerDown = function () { | ||
pointersDown++; | ||
onScroll(); | ||
}); | ||
document.addEventListener('pointerup', function () { | ||
}; | ||
var onPointerUp = function () { | ||
pointersDown--; | ||
onScroll(); | ||
}); | ||
}; | ||
var initialize = function () { | ||
window.addEventListener('scroll', onScroll); | ||
window.addEventListener('resize', onResize); | ||
document.addEventListener('pointerdown', onPointerDown); | ||
document.addEventListener('pointerup', onPointerUp); | ||
onScroll(); | ||
}; | ||
var destroy = function () { | ||
window.removeEventListener('scroll', onScroll); | ||
window.removeEventListener('resize', onResize); | ||
document.removeEventListener('pointerdown', onPointerDown); | ||
document.removeEventListener('pointerup', onPointerUp); | ||
}; | ||
initialize(); | ||
@@ -209,2 +219,3 @@ var run = function () { | ||
getVisibleHeight: getVisibleHeight, | ||
destroy: destroy, | ||
}; | ||
@@ -214,2 +225,1 @@ } | ||
exports.hidingHeader = hidingHeader; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "hiding-header", | ||
"version": "0.8.4", | ||
"version": "0.9.0", | ||
"description": "Toggles header visibility on scroll.", | ||
@@ -10,4 +10,6 @@ "main": "./dist/index.js", | ||
"start": "rollup -c -w", | ||
"demo": "serve", | ||
"dev": "concurrently npm:start npm:demo", | ||
"build": "rollup -c", | ||
"prepublish": "npm run build" | ||
"prepare": "npm run build" | ||
}, | ||
@@ -34,2 +36,3 @@ "repository": { | ||
"@types/resize-observer-browser": "^0.1.5", | ||
"concurrently": "^8.0.1", | ||
"prettier": "^2.1.2", | ||
@@ -41,2 +44,3 @@ "rollup": "^2.33.1", | ||
"rollup-plugin-typescript2": "^0.29.0", | ||
"serve": "^14.2.0", | ||
"typescript": "^4.0.5" | ||
@@ -43,0 +47,0 @@ }, |
@@ -59,21 +59,14 @@ # Hiding Header [![npm](https://img.shields.io/npm/v/hiding-header.svg)](https://www.npmjs.com/package/hiding-header) ![npm type definitions](https://img.shields.io/npm/types/hiding-header.svg) | ||
// … | ||
instance.pause() // Pauses recalculations of sticky boundaries on scroll | ||
instance.isPaused() // Check if paused | ||
instance.run() // Reactivates | ||
// … | ||
instance.destroy() // Removes all internal event listeners | ||
// … | ||
instance.reveal() // Reveals header if hidden | ||
instance.hide() // Hides header if visible | ||
// … | ||
// … | ||
instance.getHeight() // Returns content height in pixels | ||
instance.getVisibleHeight() // Returns height of visible content area in pixels | ||
// … | ||
// … | ||
instance.isHome() // Returns true if element is at initial position, e.g. user has not yet scrolled | ||
// … | ||
``` | ||
@@ -80,0 +73,0 @@ |
482
23178
12
7
84