Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yowainwright committed Oct 30, 2016
0 parents commit c737c2d
Show file tree
Hide file tree
Showing 16 changed files with 3,441 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015-rollup"],
}
34 changes: 34 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false
indent_style = space
indent_size = 2

[*.css]
indent_style = space
indent_size = 2

[*.html]
indent_style = space
indent_size = 2

[*.{diff,md}]
trim_trailing_whitespace = false
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [ "airbnb/base"],
"rules": {
"indent": 2
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bower_components/*
node_modules/*
.tags
.tags1
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
src/*
gulpfile.js
rollup.config.js
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016 Jeff Wainwright

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added README.md
Empty file.
31 changes: 31 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "stickybits",
"description": "stickybits is a tool to make sticky dom elements",
"main": "dist/stickybits.js",
"authors": [
"Jeff Wainwright <[email protected]>"
],
"license": "MIT",
"keywords": [
"stick",
"fixed",
"sticky",
"position",
"navigation",
"nav",
"dom",
"simple",
"javascript",
"stuck",
"waypoint",
"scroll"
],
"homepage": "https://github.com/dollarshaveclub/stickybits",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
41 changes: 41 additions & 0 deletions dist/stickybits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.stickybits = factory());
}(this, (function () { 'use strict';

function stickybit(target, opts) {
var els = typeof target === 'string' ? document.querySelectorAll(target) : target;
if (!('length' in els)) els = [els];

var defaults = {
classname: 'js-stickybit',
position: 0,
starts: 0,
stops: 0,
stuck: 'top'
};
var classname = opts && opts.classname || defaults.classname;
var position = opts && opts.position || defaults.position;
var starts = opts && opts.starts || defaults.starts;
var stops = opts && opts.stops || defaults.stops;
var stuck = opts && opts.stuck || defaults.stuck;

for (var i = 0; i < els.length; i++) {
var el = els[i];
// stuff
}
}

var plugin = window.$ || window.jQuery || window.Zepto;
if (plugin) {
plugin.fn.extend({
stickybit: function stickybitFunc(opts) {
return stickybit(this, opts);
}
});
}

return stickybit;

})));
8 changes: 8 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const gulp = require('gulp');
const qunit = require('node-qunit-phantomjs');

gulp.task('test', function() {
qunit('tests/index.html');
});

gulp.task('default', ['test']);
56 changes: 56 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "stickybits",
"version": "0.0.1",
"description": "stickybits is a tool to make sticky dom elements",
"main": "dist/stickybits.js",
"files": [
"dist"
],
"keywords": [
"stick",
"fixed",
"sticky",
"position",
"navigation",
"nav",
"dom",
"simple",
"javascript",
"stuck",
"waypoint",
"scroll"
],
"scripts": {
"test": "gulp test",
"postpublish": "git tag $npm_package_version && git push origin --tags"
},
"bugs": {
"url": "https://github.com/dollarshaveclub/stickybits/issues"
},
"homepage": "https://github.com/dollarshaveclub/stickybits#readme",
"repository": {
"url": "https://github.com/dollarshaveclub/stickybits.git",
"type": "git"
},
"author": "Jeff Wainwright <[email protected]>",
"license": "MIT",
"dependencies": {
"babel-core": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-es2015-rollup": "^1.2.0",
"bower": "^1.7.9",
"debug": "^2.2.0",
"eslint": "^3.9.0",
"eslint-config-airbnb": "^12.0.0",
"eslint-plugin-import": "^2.0.1",
"gulp": "^3.9.1",
"node-qunit-phantomjs": "^1.4.0",
"qunit": "^0.9.1",
"rollup": "^0.36.3",
"rollup-plugin-babel": "^2.6.1",
"rollup-plugin-commonjs": "^5.0.5",
"rollup-plugin-eslint": "^3.0.0",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-uglify": "^1.0.1"
}
}
27 changes: 27 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import babel from 'rollup-plugin-babel';
import eslint from 'rollup-plugin-eslint';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';

export default {
entry: 'src/stickybits.js',
dest: 'dist/stickybits.js',
format: 'umd',
moduleName: 'stickybits',
sourceMap: false, // removes the souremap at the bottom of the file
plugins: [
resolve({
jsnext: true,
main: true,
browser: true,
}),
commonjs(),
eslint({
exclude: []
}),
babel({
exclude: 'node_modules/**',
}),
],
};
31 changes: 31 additions & 0 deletions src/stickybits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export default function stickybit(target, opts) {
let els = typeof target === 'string' ? document.querySelectorAll(target) : target;
if (!('length' in els)) els = [els];

const defaults = {
classname: 'js-stickybit',
position: 0,
starts: 0,
stops: 0,
stuck: 'top',
};
const classname = opts && opts.classname || defaults.classname;
const position = opts && opts.position || defaults.position;
const starts = opts && opts.starts || defaults.starts;
const stops = opts && opts.stops || defaults.stops;
const stuck = opts && opts.stuck || defaults.stuck;

for (let i = 0; i < els.length; i++) {
const el = els[i];
// stuff
}
}

const plugin = window.$ || window.jQuery || window.Zepto;
if (plugin) {
plugin.fn.extend({
stickybit: function stickybitFunc(opts) {
return stickybit(this, opts);
},
});
}
32 changes: 32 additions & 0 deletions tests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" media="all" href="https://cdnjs.cloudflare.com/ajax/libs/qunit/2.0.1/qunit.css">
<style>p {max-width: 18.75rem;margin: 1rem auto;}</style></head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<nav id="main-sticky">Main Sticky</nav>
<main>
<div class="test">
<nav id="sticky-test-1">Test 1</nav>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam sollicitudin consequat eros, non posuere justo hendrerit quis. Integer eget risus dapibus, rutrum nisl sit amet, posuere dui. Cras vitae urna ac urna placerat vulputate. Morbi et tortor vel nisi rutrum consequat. Pellentesque non sem cursus, rhoncus nisi sed, semper quam. Phasellus efficitur iaculis auctor. Pellentesque at aliquam leo. Proin diam nulla, mollis vitae nibh sit amet, interdum suscipit risus. Sed fermentum leo enim, a pretium ipsum sollicitudin non. Nunc tempus nunc sed laoreet porttitor. Duis varius purus pellentesque luctus vestibulum. In ex dui, maximus vitae nisl a, molestie malesuada purus. Duis semper est in varius mattis. Pellentesque mollis convallis ex eu pretium.
Vivamus eleifend nunc a sem euismod, non consequat purus varius. Donec hendrerit eleifend ex ac cursus. Ut ac nibh quis massa rhoncus accumsan. Praesent ultricies arcu quis magna tempus, vitae tristique diam euismod. Proin accumsan quam magna, quis condimentum diam lacinia et. Quisque tempor tellus neque, vitae facilisis dui mollis sit amet. Sed sit amet augue ac mi cursus egestas nec gravida velit. Suspendisse eu nunc tristique lorem eleifend vulputate. Aliquam viverra ex sed augue mollis, eu feugiat purus volutpat. Donec consectetur a lectus ac accumsan. Aenean massa libero, pellentesque a ultrices nec, commodo eget neque. Duis blandit augue et tempus egestas. Aenean facilisis lectus eget venenatis blandit. Nam porta sollicitudin erat, at fermentum eros iaculis ut.
</p>
</div>
<div class="test-2">
<nav id="sticky-test-2">Test 2</nav>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</p>
</div>
<div id="test-bottom" class="test-3">
<nav id="sticky-test-3">Test 3</nav>
<p class="test-2">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</p>
</div>
</main>
<script src="https://code.jquery.com/jquery-3.1.0.slim.min.js" integrity="sha256-cRpWjoSOw5KcyIOaZNo4i6fZ9tKPhYYb6i5T9RSVJG8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qunit/2.0.1/qunit.js"></script>
<script src="../dist/shave.js"></script><script src="tests.js"></script>
</body></html>
Empty file added tests/test.js
Empty file.
Loading

0 comments on commit c737c2d

Please sign in to comment.