diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 00000000..8e7865fb
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,25 @@
+{
+ "env": {
+ "browser": true,
+ "node": true
+ },
+
+ "rules": {
+ "brace-style": [1, "stroustrup"],
+ "consistent-this": [1, "self"],
+ "eqeqeq": [1, "smart"],
+ "func-style": [1, "declaration"],
+ "no-else-return": 1,
+ "no-extra-parens": 1,
+ "no-floating-decimal": 1,
+ "no-nested-ternary": 1,
+ "no-lonely-if": 1,
+ "quotes": [1, "single", "avoid-escape"],
+ "radix": 1,
+ "semi": [1, "never"],
+ "space-after-keywords": [1, "always"],
+ "space-in-brackets": [1, "never"],
+ "space-unary-word-ops": 1,
+ "wrap-iife": 1
+ }
+}
diff --git a/.gitignore b/.gitignore
index 23246a9e..7f0e595b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
+_site
.sass-cache
.DS_Store
/style.scss
*.gz
-node_modules
\ No newline at end of file
+node_modules
+bower_components
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 00000000..f4910ba7
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,7 @@
+language: node_js
+sudo: false
+node_js:
+ - "0.10"
+before_script:
+ - npm install -g bower
+ - bower install
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 53b206a5..bf0e6acb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,50 @@
# Changelog
+## v4.0.1
+
+- Improve performance of `enableAll`. (Issue #454)
+- Handle edge case bug where Waypoint initialization during a specific part of iOS scroll bounce would cause an immediate trigger of it. (Issue #499)
+- Maintain `window` Context/resize-handler even when there are only non-window-context waypoints. (Issue #442)
+
+## v4.0.0
+
+- Allow Sticky option `wrapper` to accept false, which will not create a wrapper and instead use the preexisting parent element. (Pull #416)
+- Waypoints that are immediately triggered on creation because they've already passed their trigger point now run their handlers on the next animation frame. This contains Zalgo. (Issue #384)
+- Pass the jQuery object of items added during an Infinite page load to the `onAfterPageLoad` callback. (Pull #398)
+- Add `enabled` option, `enable` and `disable` methods to the Inview shortcut (Pull #406)
+- Make the Inview instance `this` within the callbacks, rather than the invdividual underlying waypoints. (Issue #412)
+- Account for changes to jQuery 3 around calling `offset` on the window. (Pull #430)
+- Add `context` option to Inview. (Issue #433)
+
+## v3.1.1
+
+- Fix bad `isWindow` checks causing errors in IE8-. (Issue #372)
+
+## v3.1.0
+
+- Add `Waypoint.disableAll` and `Waypoint.enableAll` methods.
+- Fix Illegal Invocation errors stemming from non-window context use of `requestAnimationFrame`. (Pull #366)
+- Keep disabled waypoints from triggering debug script errors. (Pull #365)
+- Allow Infinite Scroll items to be root elements in the AJAX response. (Pull #361)
+- In debug script, detect display none and fixed positioning defined in CSS.
+
+## v3.0.1
+
+- Add semicolons to the end of built files to aid in clean concatenation. (Issue #353)
+
+## v3.0.0
+
+- Remove hard jQuery dependency. Create builds for jQuery, Zepto, and no DOM framework. (Issue #282)
+- Expose `Waypoint` and `Context` classes. (Issue #281)
+- Add `Group` class and `group` option for grouping waypoints. Make `continuous` option work within these groups. (Issue #264)
+- Add Inview shortcut. (Issue #131)
+- Extend `continuous` option to cover refreshes. (Issue #166)
+- Throttle resize and scroll handlers using `requestAnimationFrame` instead of a set millisecond timeout. Fallback to the old 60 FPS `setTimeout` throttle for unsupported browsers. (Issue #242)
+- Add debugging script for diagnosing common problems.
+- Remove `triggerOnce` option.
+- Add `viewportWidth` utility method.
+- Remove all traces of CoffeeScript.
+
## v2.0.5
- Allow sticky users to define which direction the stuck class shold be applied. (Issue #192)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..8e6e9b18
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,31 @@
+# Opening an Issue
+
+The GitHub issue tracker is exclusively for opening demonstrable bugs with the library or for discussing/implementing enhancements. If you need general help with Waypoints try searching through existing closed tickets, searching through the [#jquery-waypoints](http://stackoverflow.com/questions/tagged/jquery-waypoints) tag on StackOverflow, or asking your question there using that tag. If you do ask a question on StackOverflow, please follow the guidelines for [asking a good question](http://stackoverflow.com/help/how-to-ask).
+
+If you're opening a ticket for a bug:
+
+- Give a clear explanation of the bug.
+- Try to provide a link to a [JSFiddle](http://jsfiddle.net/) or [CodePen](http://codepen.io/) or similar reduced test case.
+- If you cannot provide a reduced test case, please provide a link to a live site demonstrating your bug and include in the ticket the relevant Waypoints code.
+
+If you're interested in discussing a possible new feature:
+
+- Search closed tickets for discussions that may have already occurred.
+- Open a ticket and let's talk!
+
+# Pull Requests
+
+- Please send the pull request against the master branch.
+- Note any tickets that the pull request addresses.
+- Add any necessary tests (see below).
+- Follow the coding style of the current codebase.
+
+# Tests
+
+Tests are written in [Jasmine](http://jasmine.github.io/) and run through the [testem](https://github.com/airportyh/testem) test runner. To run them locally you'll need to:
+
+- Install, if you haven't already: [PhantomJS](http://phantomjs.org/), node, and [Bower](bower.io).
+- `npm install`
+- `bower install`
+
+You can then run the tests one time by running `npm test`, or enter TDD mode by running `npm run tdd`.
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 1513ef4a..00000000
--- a/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-COFFEE = ./node_modules/coffee-script/bin/coffee
-UGLIFY = ./node_modules/uglify-js/bin/uglifyjs
-
-setup:
- npm install
-
-build: compile minify
-
-compile:
- $(COFFEE) --compile waypoints.coffee shortcuts/*/*.coffee
-
-minify:
- $(UGLIFY) -m --comments all -o waypoints.min.js waypoints.js
- $(UGLIFY) -m --comments all -o shortcuts/infinite-scroll/waypoints-infinite.min.js shortcuts/infinite-scroll/waypoints-infinite.js
- $(UGLIFY) -m --comments all -o shortcuts/sticky-elements/waypoints-sticky.min.js shortcuts/sticky-elements/waypoints-sticky.js
-
-.PHONY: setup build compile minify
\ No newline at end of file
diff --git a/README.markdown b/README.markdown
deleted file mode 100644
index 09adba92..00000000
--- a/README.markdown
+++ /dev/null
@@ -1,47 +0,0 @@
-# jQuery Waypoints
-
-Waypoints is a jQuery plugin that makes it easy to execute a function whenever you scroll to an element.
-
-```js
-$('.thing').waypoint(function() {
- alert('You have scrolled to a thing.');
-});
-```
-If you're new to Waypoints, check out the [Get Started](http://imakewebthings.github.com/jquery-waypoints/#get-started) section.
-
-[Read the full documentation](http://imakewebthings.github.com/jquery-waypoints/#docs) for more details on usage and customization.
-
-## Shortcuts
-
-In addition to the normal Waypoints script, extensions exist to make common UI patterns just a little easier to implement:
-
-- [Infinite Scrolling](http://imakewebthings.github.com/jquery-waypoints/shortcuts/infinite-scroll)
-- [Sticky Elements](http://imakewebthings.github.com/jquery-waypoints/shortcuts/sticky-elements)
-
-## Examples
-
-Waypoints can also be used as a base for your own custom UI patterns. Here are a few examples:
-
-- [Scroll Analytics](http://imakewebthings.github.com/jquery-waypoints/examples/scroll-analytics)
-- [Dial Controls](http://imakewebthings.github.com/jquery-waypoints/examples/dial-controls)
-
-## AMD Module Loader Support
-
-If you're using an AMD loader like [RequireJS](http://requirejs.org/), Waypoints registers itself as a named module, `'waypoints'`. Shortcut scripts are anonymous modules.
-
-## Development Environment
-
-If you want to contribute to Waypoints, I love pull requests that include changes to the source `coffee` files as well as the compiled JS and minified files. You can set up the same environment by running `make setup` (which just aliases to `npm install`). This will install the version of CoffeeScript and UglifyJS that I'm using. From there, running `make build` will compile and minify all the necessary files. Test coffee files are compiled on the fly, so compile and minify do not apply to those files.
-
-## License
-
-Copyright (c) 2011-2014 Caleb Troughton
-Licensed under the [MIT license](https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt).
-
-## Support
-
-Unit tests for Waypoints are written with [Jasmine](http://pivotal.github.com/jasmine/) and [jasmine-jquery](https://github.com/velesin/jasmine-jquery). You can [run them here](http://imakewebthings.github.com/jquery-waypoints/test/). If any of the tests fail, please open an issue and include the browser used, operating system, and description of the failed test.
-
-## Donations
-
-[](https://www.gittip.com/imakewebthings/ "Donate weekly to this project using Gittip")
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..af686851
--- /dev/null
+++ b/README.md
@@ -0,0 +1,33 @@
+# Waypoints
+
+Waypoints is a library that makes it easy to execute a function whenever you scroll to an element. 
+
+```js
+var waypoint = new Waypoint({
+ element: document.getElementById('thing'),
+ handler: function(direction) {
+ alert('You have scrolled to a thing')
+ }
+})
+```
+
+If you're new to Waypoints, check out the [Getting Started](http://imakewebthings.com/waypoints/guides/getting-started) guide.
+
+[Read the full documentation](http://imakewebthings.com/waypoints/api/waypoint) for more details on usage and customization.
+
+## Shortcuts
+
+In addition to the normal Waypoints script, extensions exist to make common UI patterns just a little easier to implement:
+
+- [Infinite Scrolling](http://imakewebthings.com/waypoints/shortcuts/infinite-scroll)
+- [Sticky Elements](http://imakewebthings.com/waypoints/shortcuts/sticky-elements)
+- [Inview Detection](http://imakewebthings.com/waypoints/shortcuts/inview)
+
+
+## Contributing
+
+If you want to report a Waypoints bug or contribute code to the library, please read the [Contributing Guidelines](https://github.com/imakewebthings/waypoints/blob/master/CONTRIBUTING.md). If you need help *using* Waypoints, please do not open an issue. Instead, ask the question on [Stack Overflow](http://stackoverflow.com) and tag it with #jquery-waypoints. Be sure to follow the guidelines for [asking a good question](http://stackoverflow.com/help/how-to-ask).
+
+## License
+
+Copyright (c) 2011-2014 Caleb Troughton. Licensed under the [MIT license](https://github.com/imakewebthings/waypoints/blob/master/licenses.txt).
diff --git a/bower.json b/bower.json
index 340f185e..01f3cde6 100644
--- a/bower.json
+++ b/bower.json
@@ -1,19 +1,18 @@
{
- "name": "jquery-waypoints",
- "version": "2.0.5",
- "main": "waypoints.js",
- "description": "A jQuery plugin that makes it easy to execute a function whenever you scroll to an element.",
+ "name": "waypoints",
+ "main": "lib/noframework.waypoints.js",
+ "description": "Easily execute a function when you scroll to an element.",
"ignore": [
- "**/.*",
- "**/*.coffee",
- "**/*.html",
- "bower_components",
- "examples",
- "node_modules",
- "Makefile",
- "test"
+ "gulpfile.js",
+ "package.json",
+ "src",
+ "test",
+ "testem.json"
],
- "dependencies": {
- "jquery" : ">=1.8"
+ "devDependencies": {
+ "jquery": "~1.11.1",
+ "lodash": "~2.4.1",
+ "jasmine-jquery": "~1.7.0",
+ "zepto": "~1.1.3"
}
}
diff --git a/examples/dial-controls/index.html b/examples/dial-controls/index.html
deleted file mode 100644
index c59ce717..00000000
--- a/examples/dial-controls/index.html
+++ /dev/null
@@ -1,292 +0,0 @@
-
-
-
-
$('.dial li').waypoint( function(direction) {
- var $active = $(this);
- var property, value;
-
- /* The waypoint is triggered at the top of each list item representing a dial section. When triggering in the down direction we want to use the dial section the waypoint is attached to. But in the up direction we want to use the previous dial section. */
- if (direction === "up") {
- $active = $active.prev();
- }
-
- /* If we triggered in the up direction and the result from 'prev' came back with an empty set of elements, it means we were on the first element in the list, and we should just use the original element. */
- if (!$active.length) {
- $active = $(this);
- }
-
- /* The property the dial controls is a data attribute on the ul. */
- property = $active.closest('.dial').data('property');
-
- /* The value for that property is a data attribute on each li. */
- value = $active.data('value');
-
- $('#example-target').css(property, value);
-}, {
- context: 'ul' // Make the scroll context the nearest ul.
-});
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut mi eros, commodo vel porttitor vitae, facilisis eu quam. Suspendisse elementum nibh vel velit bibendum vitae accumsan sem pellentesque. Aliquam quis nisl in felis elementum facilisis. Suspendisse potenti. Suspendisse vel ligula erat, mollis sagittis tortor. Vestibulum lobortis rutrum sapien, id sodales leo hendrerit in. Nullam at risus et lectus mattis elementum. Aliquam porta dignissim leo id iaculis. Donec id magna turpis. Morbi convallis lacus gravida velit condimentum suscipit. Nunc dui ipsum, congue sit amet euismod in, aliquet quis mauris. Mauris quis libero a diam egestas gravida. Phasellus bibendum, sem quis vulputate consectetur, quam nulla feugiat sem, eu sodales mi velit a tellus.
- -Sed posuere pellentesque consequat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut non faucibus lorem. Curabitur condimentum viverra lorem, eu suscipit mi vehicula ac. Mauris mattis, purus at vehicula ultricies, dolor quam tempus eros, in eleifend neque nulla at urna. Duis consequat faucibus pellentesque. Nulla facilisi. Maecenas id pellentesque sapien. Sed lobortis lectus vel nibh semper placerat. Pellentesque non diam lectus.
- -Suspendisse pellentesque tempor est a cursus. Aliquam molestie, neque vitae ullamcorper dictum, velit mi varius justo, id blandit mauris dui a felis. Curabitur tortor arcu, ornare in tempor sit amet, varius ac elit. Nullam eleifend cursus consectetur.
- -Proin enim odio, vulputate non lacinia ut, iaculis et nisl. Sed bibendum, nulla vitae vestibulum tempor, urna nisi ullamcorper tortor, ut lacinia elit sapien sit amet metus. Duis congue sollicitudin elit, egestas porta ante pharetra id. Fusce dictum fermentum eros vitae interdum. In a justo nunc. Phasellus vel mi ante. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus ac turpis in mauris posuere eleifend.
- -Praesent congue vehicula laoreet. Pellentesque quis purus et felis condimentum suscipit.
- -Nulla ultrices pulvinar quam, et hendrerit turpis rutrum nec. Maecenas tortor ligula, ultricies eget sagittis fringilla, malesuada eu risus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur tempor, eros et aliquet congue, nunc nunc accumsan leo, sit amet ultrices magna sapien sit amet libero. Nunc iaculis diam non odio imperdiet nec aliquam sapien aliquet. Donec vulputate mi nec metus vehicula nec pretium orci accumsan. Cras non ante metus, eu interdum nulla. Morbi porttitor commodo varius. Integer vel nisi sit amet enim pellentesque convallis.
- -Sed vitae libero sem. Morbi vel tincidunt libero. Quisque suscipit adipiscing mauris eget vestibulum. Mauris euismod ante nec felis varius ultricies. Nam lacinia blandit hendrerit. Sed mattis tortor vitae tellus sodales tincidunt. Nulla tellus eros, fringilla nec posuere tincidunt, semper a odio. Mauris justo neque, placerat ac dictum lobortis, tempor vel arcu. Quisque a mi at lacus vestibulum placerat a eu leo. Sed pharetra metus vitae nisi molestie aliquam. Curabitur feugiat aliquet lorem et suscipit.
- -Fusce tincidunt tincidunt elit vitae pulvinar. Ut id magna ut massa faucibus vehicula. Nunc rutrum eros quis nunc hendrerit porta. Nullam porttitor eleifend mauris, eget interdum velit rutrum egestas. Sed iaculis eros at mauris ultricies fermentum. Duis nec nunc ut leo cursus luctus eget ac nisl. Sed condimentum euismod nulla, ut auctor lectus fringilla sit amet. Proin ac magna eros, nec euismod nibh. Integer tellus velit, accumsan ut vulputate quis, vehicula sit amet urna. Aliquam ornare libero vitae ipsum pellentesque quis consequat mi varius. Aliquam a urna a nunc tristique volutpat. Nulla eu mi sit amet dolor dapibus bibendum. Aenean commodo, enim non tristique ultrices, nisi dolor rhoncus metus, ac porta tortor felis at quam. Donec a dui felis. Etiam id aliquam tortor.
- -Suspendisse a rutrum purus.
- -Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec in quam metus, sed pharetra nisi. Nunc lacinia arcu eget eros molestie blandit.
- -Ut at sem ut nibh molestie tempus. Nunc volutpat malesuada massa, vel auctor odio consequat consectetur. Suspendisse scelerisque nunc non quam suscipit vestibulum. Aliquam eu turpis sem, non ultrices tellus. Pellentesque vel velit lectus, a imperdiet arcu. Vivamus et turpis in libero consectetur gravida non id massa. Morbi ut urna mi. Phasellus pellentesque congue porttitor.
- -Vivamus eu dolor urna, vel malesuada orci. Vivamus pellentesque tellus non tortor scelerisque consequat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Pellentesque lacinia nibh consequat purus lobortis pretium. Sed lobortis fringilla auctor. Aliquam erat volutpat. Maecenas mollis lorem quis mauris pharetra non posuere dui luctus.
- -Fusce tempor magna et metus rutrum volutpat. In pellentesque enim nec augue pretium egestas. Pellentesque viverra mauris eget enim rutrum sagittis vulputate ligula lobortis. Integer bibendum porttitor turpis at adipiscing. Nulla vulputate, ligula id adipiscing pharetra, lectus magna varius elit.
- -A feugiat nisi nulla ut lorem. Etiam eu dui vitae erat molestie dignissim lacinia ac quam. Cras bibendum consequat risus sed tristique. Morbi mattis ultrices eros id iaculis. Maecenas vel euismod tellus. Aenean aliquet rhoncus quam ut gravida. Sed faucibus metus tellus, vitae suscipit neque. Morbi et odio vitae sem tempor eleifend. Praesent sagittis, magna sit amet commodo convallis, nibh lectus blandit sapien, vel congue lorem purus vitae magna. Curabitur velit metus, lacinia eu rhoncus at, facilisis eget est. Curabitur metus augue, ultricies id vehicula eget, tempor dignissim ipsum.
-A feugiat nisi nulla ut lorem. Etiam eu dui vitae erat molestie dignissim lacinia ac quam. Cras bibendum consequat risus sed tristique. Morbi mattis ultrices eros id iaculis. Maecenas vel euismod tellus. Aenean aliquet rhoncus quam ut gravida. Sed faucibus metus tellus, vitae suscipit neque. Morbi et odio vitae sem tempor eleifend. Praesent sagittis, magna sit amet commodo convallis, nibh lectus blandit sapien, vel congue lorem purus vitae magna. Curabitur velit metus, lacinia eu rhoncus at, facilisis eget est. Curabitur metus augue, ultricies id vehicula eget, tempor dignissim ipsum.
- -First include the shortcut script.
- -<script src="/path/to/waypoints-infinite.min.js"></script>
-
- The Infinite Scroll shortcut is used to transform a traditional "Next Page" navigation into an AJAX-powered infinite scrolling UI pattern. Its default usage looks like this:
- -$('.infinite-container').waypoint('infinite');
-
- In this example, our shortcut will create a waypoint to be fired when the bottom of .infinite-container comes into view. When that waypoint fires it will go through several steps:
onBeforePageLoad callback. This callback can be passed to the infinite shortcut in the options object. For our simple example, we have no callback.infinite-loading class to the container. This class gives us a way to style the container during loading. It should be used to give the user a hint that more content is being loaded.infinite-more-link and use its href as the new location to fetch.infinite-item and appends them to the container.infinite-more-link and replaces the existing one.infinite-loading class.onAfterPageLoad callback. As with the first callback, this can be passed in as an option but defaults to a no-op.These steps are repeated every time the user reaches the bottom of the container until the AJAX request does not return a "more" link element, as this indicates we're on the last page. At that point the waypoint is destroyed.
- -The "infinite" waypoint function accepts a number of options in addition to the usual Waypoints options. Here are the defaults:
-First include the shortcut script.
- -<script src="/path/to/waypoints-sticky.min.js"></script>
-
- The Sticky Elements shortcut is used to make elements "stick" to the top of the page when the user scrolls past. It packages a few best practices around this pattern into one simple function extension of jQuery Waypoints. The most basic usage looks like this:
- -$('.my-sticky-element').waypoint('sticky');
-stuck class.stuck elements fixed positioning. It is left to you, the author, to give the stuck elements fixed positioning in CSS. With so many design possibilities, the script cannot make any assumptions about how the sticky element should look. The shortcut only goes as far as to add the class to give you a hook for this styling.The "sticky" waypoint method may also be passed an options object. This options object can be used to override the class name of the "stuck" state, the direction(s) in which the stuck class should be applied, and the HTML of the wrapper element. Here are the defaults:
- -$('.my-sticky-element').waypoint('sticky', {
- direction: 'down right',
- stuckClass: 'stuck',
- wrapper: '<div class="sticky-wrapper" />'
-});
-
- This options object is just an extension of the regular Waypoints options object, so you can pass along any traditional options you may want. A common one is the offset option.
$('.my-sticky-element').waypoint('sticky', {
- offset: 30 // Apply "stuck" when element 30px from top
-});
-