Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.4.4 includes touch fix for mobile devices, also osx inertia problem f... #14

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# jQuery Scroll Sections Plugin (Version 0.4.3)
# jQuery Scroll Sections Plugin (Version 0.4.4)

A plugin that allows you to define (full page) sections and scroll between them with mousewheel, keyboard, scrollbar and/or touch moves.

Here is a very simple [demo](http://lab.stephaneguigne.com/js/jquery-scrollsections/example/callbacks.html)
Here is a very simple [demo](http://)


## Requirement (for a full support)
Expand Down Expand Up @@ -76,12 +76,10 @@ Modern browsers: Chrome, Firefox, Safari, Opera and IE8+

## License

Under [MIT license](http://opensource.org/licenses/MIT)


Under [MIT license](http://opensource.org/licenses/MIT)
Copyright(c) 2011-2013 [Stéphane Guigné](http://stephaneguigne.com)


## Logs

v0.4.3 - send back arguments to callback functions
v0.4.4 - fixed mobile touch issues, fixed osx inertia problem with apple magic mouse and trackpad.
v0.4.3 - send back arguments to callback functions
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

jQuery ScrollSections Plugin

* @version 0.4.3
* @version 0.4.4
* @link https://github.com/guins/jquery-scrollsections
* @author Stéphane Guigné <http://stephaneguigne.com/>
* @author Richard Fussenegger <http://richard.fussenegger.info/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

jQuery ScrollSections Plugin

* @version 0.4.3
* @version 0.4.4
* @link https://github.com/guins/jquery-scrollsections
* @author Stéphane Guigné <http://stephaneguigne.com/>
* @author Richard Fussenegger <http://richard.fussenegger.info/>
Expand Down
9 changes: 0 additions & 9 deletions build/js/jquery.scrollSections-0.4.3.min.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ A plugin that allows you to define (full page) sections and scroll between them
- jQuery mousewheel if you want mousewheel support {@link https://github.com/brandonaaron/jquery-mousewheel}
- jQuery Special Events scrollstart & scrollstop if you want scrollbar support {@link http://james.padolsey.com/demos/scrollevents/}
*
* @version 0.4.3
* @version 0.4.4
* @link https://github.com/guins/jquery-scrollsections
* @author Stéphane Guigné <http://stephaneguigne.com/>
* @author Richard Fussenegger <http://richard.fussenegger.info/>
* @license MIT
* @copyright (c) 2011-2013, Stéphane Guigné
*
* Last modification : 2013-08-16
* Last modification : 2014-12-03
*
*/

Expand Down Expand Up @@ -269,23 +269,32 @@ A plugin that allows you to define (full page) sections and scroll between them
var self = this;

this._$body.bind('touchstart', function (event) {
var startEvent = event;
var startEvent = event.originalEvent.touches[0];

event.preventDefault();
self._$body.bind('touchmove', function (event) {
var diff = { x: startEvent.clientX - event.clientX, y: startEvent.clientY - event.clientY };
self._$body.unbind('touchmove.myNameSpace').bind('touchmove.myNameSpace', function (event) {
var moveEvent = event.originalEvent.touches[0];
var diff = { x: startEvent.clientX - moveEvent.clientX, y: startEvent.clientY - moveEvent.clientY };
var nextStep;
event.preventDefault();
if ((diff.y <= -100 || diff.y >= 100) && Math.abs(diff.y) > Math.abs(diff.x)) {
nextStep = diff.y < 0 ? self._currentStep - 1 : self._currentStep + 1;
self.customScrollTo(nextStep);

// Unbind all touchmove.myNameSpace events.
self._$body.unbind('touchmove.myNameSpace');
}
return false;
});

return false;
});

// Unbind all touchmove.myNameSpace events on touchend.myNameSpace.
self._$body.bind('touchend.myNameSpace', function (event) {
self._$body.unbind('touchmove.myNameSpace');
});

return this;
},

Expand Down Expand Up @@ -439,14 +448,35 @@ A plugin that allows you to define (full page) sections and scroll between them
}
}





// Fix for inertia skipping sections
var prevTime = new Date().getTime();

this._$window.mousewheel(function (event, delta, deltaX, deltaY) {



// Fix for inertia skipping sections
var curTime = new Date().getTime();
var fireEvent = false;
if (typeof prevTime !== 'undefined') {
var timeDiff = curTime-prevTime;
if (timeDiff > 50) {fireEvent = true;}
}
prevTime = curTime;



var stepDiff = null;
var nextStep = -1;

event.preventDefault();

// Only scroll if we are not animating and scrolling is not paused.
if (!(self._isAnimated && self._scrollPaused)) {
if (!(self._isAnimated && self._scrollPaused) && fireEvent) {

deltaY = deltaY>>0; // Because steps numbers are integers

Expand Down
9 changes: 9 additions & 0 deletions build/js/jquery.scrollSections-0.4.4.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions example/callbacks.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@

<script src="js/vendor/jquery-1.7.2.min.js"></script>
<script src="js/plugins.js"></script>
<!-- <script src="../src/js/jquery.scrollSections.js"></script> -->
<script src="../build/js/jquery.scrollSections-0.4.3.min.js"></script>
<script src="../src/js/jquery.scrollSections.js"></script>
<script>
$(function() {

Expand Down Expand Up @@ -124,4 +123,4 @@
</script>

</body>
</html>
</html>
1 change: 0 additions & 1 deletion example/customNavigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
<script src="js/vendor/jquery-1.7.2.min.js"></script>
<script src="js/plugins.js"></script>
<script src="../src/js/jquery.scrollSections.js"></script>
<!-- <script src="../build/js/jquery.scrollSections-0.4.1.min.js"></script> -->
<script>
$(function() {
$('section.scrollsections').scrollSections({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jquery.scrollSections",
"fullname": "jQuery ScrollSections Plugin",
"version": "0.4.3",
"version": "0.4.4",
"description": "A plugin that allows you to define (full page) sections and scroll between them with mousewheel, keyboard, scrollbar and/or touch moves.\n\n The following jQuery plugins are required for this plugin to work properly:\n - jQuery mousewheel if you want mousewheel support {@link https://github.com/brandonaaron/jquery-mousewheel}\n - jQuery Special Events scrollstart & scrollstop if you want scrollbar support {@link http://james.padolsey.com/demos/scrollevents/}",
"main": "index.js",
"url": "https://github.com/guins/jquery-scrollsections",
Expand Down
Loading