affixing-header
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "affixing-header", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "An affixing header that behaves normally as a user navigates down a page, but reveals itself naturally when a user scrolls or drags upwards. Inspired by iOS Safari, Medium, and others.", | ||
"main": "dist/affixing-header.js", | ||
"scripts": { | ||
"test": "mocha --timeout 10000", | ||
"build": "esperanto -i src/affixing-header.js -o dist/affixing-header.js -t umd -n affixingHeader", | ||
"test": "node test/bootstrap.js", | ||
"test-mocha": "mocha --reporter spec test/bootstrap.js", | ||
"build": "esperanto -b -i src/affixing-header.js -o dist/affixing-header.js -t umd -n affixingHeader", | ||
"build-install": "npm install -g esperanto;" | ||
@@ -35,2 +36,3 @@ }, | ||
"chai-as-promised": "^4.3.0", | ||
"colors": "^1.0.3", | ||
"es6-module-loader": "^0.16.1", | ||
@@ -40,9 +42,18 @@ "esperanto": "^0.6.24", | ||
"mocha": "^2.2.1", | ||
"mocha-multi": "^0.6.0", | ||
"mocha-sauce-notifying-reporter": "0.0.1", | ||
"saucelabs": "^0.1.1", | ||
"selenium-webdriver": "^2.45.1", | ||
"serve-static": "^1.9.2", | ||
"should": "^5.2.0" | ||
"serve-static": "^1.9.2" | ||
}, | ||
"dependencies": { | ||
"jank-free-onscroll": "^0.2.1" | ||
}, | ||
"jspm": { | ||
"directories": { | ||
"lib": "src" | ||
}, | ||
"main": "affixing-header", | ||
"format": "es6" | ||
} | ||
} |
@@ -1,2 +0,28 @@ | ||
# affixing-header | ||
Create an affixing header that behaves normally as a user navigates down a page, but reveals itself naturally when a user scrolls or drags upwards. Inspired by iOS Safari, Medium, and others. | ||
# Affixing Header [![Build Status](https://travis-ci.org/acusti/affixing-header.svg?branch=master)](https://travis-ci.org/acusti/affixing-header) | ||
Create an affixing header that behaves normally as a user navigates down a page, but reveals itself naturally when a user scrolls or drags upwards. Inspired by iOS Safari, Medium, and others. See an [example implementation][acusti.ca]. Works on desktop and mobile browsers. | ||
[![Sauce Test Status](https://saucelabs.com/browser-matrix/acusti.svg)](https://saucelabs.com/u/acusti) | ||
## Usage | ||
The object exports an `affixing-header` module if being used with a CommonJS or AMD module loader, or else exposes a global object as `window.affixingHeader`. | ||
### `affixingHeader( element )` | ||
#### `element` Element | ||
The DOM element to which the affixing behaviour should be attached. Must be a single Element (e.g., the result of `document.querySelector` or `document.getElementById`), not a `NodeList`. | ||
### Dependencies | ||
This package uses [jank-free onscroll][], a requestAnimationFrame-based, performant, mobile-friendly scroll event handler, to listen for page scrolls, but has no other dependencies. | ||
### Compatibility | ||
The scroll handling uses `requestAnimationFrame`, which is [only available in IE10+][raf-caniuse]. For older browsers, your header simply won?t affix when you scroll up, but you shouldn?t see any other issues (yay progressive enhancement!). To add compatibility for older browsers, just include a [requestAnimationFrame polyfill][raf-polyfill]. | ||
[acusti.ca]: http://www.acusti.ca | ||
[jank-free onscroll]: https://github.com/acusti/jank-free-onscroll | ||
[raf-caniuse]: http://caniuse.com/#feat=requestanimationframe | ||
[raf-polyfill]: https://gist.github.com/paulirish/1579671 |
@@ -57,3 +57,5 @@ 'use strict'; | ||
// If this is bounce scrolling (e.g. Mac OS, iOS), bail | ||
if (scrollY < 0 || (scrollY + window.innerHeight) > document.documentElement.scrollHeight) { | ||
// Another way to check the top | ||
//(scrollY + window.innerHeight) > document.documentElement.scrollHeight | ||
if (scrollY < 0 || document.documentElement.scrollHeight - document.documentElement.scrollTop < document.documentElement.clientHeight) { | ||
return; | ||
@@ -60,0 +62,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
37664
15
628
29
13
17
2