diff --git a/.gitignore b/.gitignore index b0eb24c..851b9e3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ build components coverage *.orig -.idea \ No newline at end of file +.idea +bower_components/ diff --git a/README.md b/README.md index f73dfbf..9d034ae 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,16 @@ A jQuery plugin that switches between multiple header designs as you scroll, so **[Check out the demo](http://aerolab.github.io/midnight.js/)** (watch the logo as you scroll). +## Installation + +Midnight is available on Bower and NPM as **midnight.js**: + +``` +bower install midnight.js + +npm install midnight.js +``` + ## Quick start Create your fixed nav (or header) as you typically would. For an example, something like this (you can use whatever markup suits you) @@ -116,8 +126,44 @@ $('nav').midnight({ }); ``` + +## Running Multiple Instances with Different Breakpoints + +If you want to run multiple instances of midnight with different breakpoints, you can use the *sectionSelector* option to choose where each nav is going to be split. + +By default, the plugin will look for all the sections with the *data-midnight* attribute, which is the default, but you can change this to suit your needs. For example: + +```js +$('nav.one').midnight({ + // By default, sectionSelector is 'midnight'. It will switch only on elements that have the data-midnight attribute. + sectionSelector: 'midnight' +}); + +$('nav.two').midnight({ + // We want this nav to switch only on elements that have the data-noon attribute. + sectionSelector: 'noon' +}); +``` + + +## CDN Hosting + +To lower hosting costs & have users load midnight.js faster, you can use the [jsDelivr CDN](http://www.jsdelivr.com/#!jquery.midnight) like so: +```htm + +``` + + +### JSDelivr + +You can use jsDelivr's [version aliasing & concocting](https://www.jsdelivr.com/features) to serve the latest minor branch version along with dependancies. For example, to download the latest patch versions of midnight.js v1.0.z together along with jQuery v1.11.z: +```htm + +``` + + ## Known Issues On iOS <7 and older Android devices scrollTop isn't updated fluently, which creates a choppy effect. It can be fixed somewhat by wrapping the body in container and detecting touch events, but we're leaving that as an open issue. We'll probably disable the effect on older mobile devices due to bad performance. -You shouldn't add any sort of padding, margin or offset (top/left/right/bottom) to the nav, since it causes issues with rendering. \ No newline at end of file +You shouldn't add any sort of padding, margin or offset (top/left/right/bottom) to the nav, since it causes issues with rendering. diff --git a/bower.json b/bower.json index 67c6184..caa6e1f 100644 --- a/bower.json +++ b/bower.json @@ -1,8 +1,11 @@ { "name": "midnight", - "version": "1.0.3", "description": "Switch fixed headers on the fly", + "version": "1.1.2", "main": "midnight.jquery.js", + "dependencies": { + "jquery": "^1.11.3" + }, "homepage": "https://github.com/Aerolab/midnight.js", "license": "MIT", "authors": [ diff --git a/gulpfile.js b/gulpfile.js index 2f16434..ee640ce 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -12,20 +12,11 @@ var getCopyright = function () { return fs.readFileSync('Copyright'); }; -gulp.task('buildfromsrc', function () { - gulp.src('./midnight.jquery.src.js') - .pipe(header(getCopyright(), {version: getVersion()})) - .pipe(concat('midnight.jquery.js')) - .pipe(gulp.dest('')); -}); - -// task -gulp.task('minifyjs', function () { +gulp.task('build', function () { gulp.src('./midnight.jquery.js') - .pipe(uglify()) - .pipe(header(getCopyright(), {version: getVersion()})) + .pipe(uglify({preserveComments:'some'})) .pipe(concat('midnight.jquery.min.js')) - .pipe(gulp.dest('')); + .pipe(gulp.dest('./')); }); -gulp.task('default', ['buildfromsrc', 'minifyjs']); \ No newline at end of file +gulp.task('default', ['build']); diff --git a/index.html b/index.html index 7391f52..d6ac500 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@