Skip to content

Commit

Permalink
Version 1.4.0 compliant with jQuery.scrollTo 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
flesler committed Mar 18, 2015
1 parent 2dd1e21 commit 1a55db8
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 73 deletions.
4 changes: 4 additions & 0 deletions changes.txt → CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.4.0
[Compat]
- Updated so it works with jQuery.scrollTo 2.0

1.3.5
[Fix]
- Fixed when lazy true, links with 2+ levels of nested elements won't work, now using $().on()
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(The MIT License)

Copyright (c) 2007-2014 Ariel Flesler <[email protected]>
Copyright (c) 2007-2015 Ariel Flesler <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ bower install jquery.localScroll

If you want the latest stable version, get the latest release from the [releases page](https://github.com/flesler/jquery.localScroll/releases).

### Notes
### jQuery.scrollTo

This plugin requires [jQuery.scrollTo](http://github.com/flesler/jquery.scrollTo).
In order to use jQuery.scrollTo 2.0 you need to update jQuery.localScroll to 1.4.0 and above.

* Requires jQuery.scrollTo (http://github.com/flesler/jquery.scrollTo)
### Notes

* The hash of settings is passed in to jQuery.scrollTo, so, in addition to jQuery.localScroll's settings, you can use any of jQuery.scrollTo's. Check that plugin's documentation for further information.

Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "jquery.localScroll",
"version": "1.3.5",
"version": "1.4.0",
"description": "Animated anchor navigation made easy.",
"homepage": "https://github.com/flesler/jquery.localScroll",
"main": [
"./jquery.localScroll.js"
],
"dependencies": {
"jquery": ">=1.8",
"jquery.scrollTo": ">=1.4.11"
"jquery.scrollTo": ">=2.0.0"
},
"keywords": [
"browser",
Expand Down
22 changes: 10 additions & 12 deletions demo/ajax/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>jQuery.LocalScroll</title>
<title>jQuery.localScroll</title>
<meta name="keywords" content="javascript, jquery, plugins, scroll, anchor, to, navigation, scrollTo, smooth, animation, ajax, overflow, element, window, lazy, effect, ariel, flesler, customizable" />
<meta name="description" content="AJAX Demo of jQuery.LocalScroll. A jQuery plugin to make anchor navigation work with a smooth animation, made by Ariel Flesler." />
<meta name="description" content="AJAX Demo of jQuery.localScroll. A jQuery plugin to make anchor navigation work with a smooth animation, made by Ariel Flesler." />
<meta name="robots" content="index,follow" />
<link type="text/css" rel="stylesheet" href="../css/ajax-style.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.scrollTo-min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery.scrollTo.min.js"></script>
<script type="text/javascript" src="../../jquery.localScroll.js"></script>
<script type="text/javascript">
jQuery(function( $ ){
Expand All @@ -20,7 +20,7 @@
last = null;// Last section

$sections.click(function(){
if( last != this ){ // let's avoid needless requests
if (last !== this) { // let's avoid needless requests
// I use the extension .ahah for a speicific reason, you use .html or .php or w/e you want.
$('#content').html( '<p class="loading">Loading...</p>' ).load( this.hash.slice(1) + '.html', function(){
this.scrollLeft = 0;//scroll back to the left
Expand All @@ -35,12 +35,12 @@

/**
* Actual call to jQuery.localScroll.
* Most jQuery.LocalScroll's defaults, belong to jQuery.ScrollTo, check it's demo for an example of each option.
* Most jQuery.localScroll's defaults, belong to jQuery.ScrollTo, check it's demo for an example of each option.
* @see http://flesler.demos.com/jquery/scrollTo/
*/

$('#content').localScroll({// only the links inside that jquery object will be affected
lazy true, // This is the KEY setting here, makes the links work even after an Ajax load.
lazy: true, // This is the KEY setting here, makes the links work even after an Ajax load.
target: '#content', // The element that gets scrolled
axis:'x', // Horizontal scrolling
duration:500,
Expand All @@ -53,7 +53,7 @@
</script>
</head>
<body>
<h1>jQuery.LocalScroll&nbsp;<strong>by Ariel Flesler</strong></h1>
<h1>jQuery.localScroll</h1>
<h2 class="title">AJAX Demo</h2>
<ul id="navigation">
<li><a href="#section1">Section 1</a></li>
Expand All @@ -68,11 +68,9 @@ <h2 class="title">AJAX Demo</h2>
<div id="links">
<h3>Links</h3>
<ul>
<li><a target="_blank" href="http://plugins.jquery.com/project/LocalScroll">Project Page</a></li>
<li><a target="_blank" href="http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html">Main blog article</a></li>
<li><a target="_blank" href="http://flesler.blogspot.com/search/label/jQuery.LocalScroll">All articles</a></li>
<li><a target="_blank" href="https://github.com/flesler/jquery.localScroll">Github</a></li>
<li><a target="_blank" href="http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html">Documentation</a></li>
<li><a href="../" rel="prev" rev="next" type="text/html">Regular Demo</a></li>
<li><a href="http://flesler.webs.com/jQuery.ScrollTo/" type="text/html">jQuery.ScrollTo's Demo</a></li>
</ul>
</div>
</body>
Expand Down
17 changes: 8 additions & 9 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>jQuery.LocalScroll</title>
<title>jQuery.localScroll</title>
<meta name="keywords" content="javascript, jquery, plugins, scroll, anchor, to, navigation, scrollTo, smooth, animation, overflow, element, window, effect, lazy, ariel, flesler, customizable" />
<meta name="description" content="Demo of jQuery.LocalScroll. A jQuery plugin to make anchor navigation work with a smooth animation, made by Ariel Flesler." />
<meta name="description" content="Demo of jQuery.localScroll. A jQuery plugin to make anchor navigation work with a smooth animation, made by Ariel Flesler." />
<meta name="robots" content="index,follow" />
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
Expand All @@ -14,8 +14,8 @@
jQuery(function( $ ){
/**
* Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
* @see http://flesler.demos.com/jquery/scrollTo/
* You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
* @see http://demos.flesler.com/jquery/scrollTo/
* You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.localScroll.
*/

// The default axis is 'y', but in this demo, I want to scroll both
Expand All @@ -42,7 +42,7 @@
</script>
</head>
<body>
<h1>jQuery.LocalScroll&nbsp;<strong>by Ariel Flesler</strong></h1>
<h1>jQuery.localScroll</h1>
<h2 class="title">Regular Demo</h2>
<ul id="navigation">
<li class="sup">
Expand Down Expand Up @@ -203,11 +203,10 @@ <h2>Section 5-c</h2>
<div id="links">
<h3>Links</h3>
<ul>
<li><a target="_blank" href="http://plugins.jquery.com/project/LocalScroll">Project Page</a></li>
<li><a target="_blank" href="http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html">Main blog article</a></li>
<li><a target="_blank" href="http://flesler.blogspot.com/search/label/jQuery.LocalScroll">All articles</a></li>
<li><a target="_blank" href="https://github.com/flesler/jquery.localScroll">Github</a></li>
<li><a target="_blank" href="http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html">Documentation</a></li>
<li><a href="ajax/" rev="prev" rel="next" type="text/html">AJAX Demo</a></li>
<li><a href="http://flesler.webs.com/jQuery.ScrollTo/" rel="prev" rev="next" type="text/html">jQuery.ScrollTo's Demo</a></li>
<li><a href="http://demos.flesler.com/jquery/scrollTo/" rel="prev" rev="next" type="text/html">jQuery.scrollTo's Demo</a></li>
</ul>
</div>
</body>
Expand Down
6 changes: 3 additions & 3 deletions demo/js/jquery.scrollTo.min.js

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

21 changes: 10 additions & 11 deletions jquery.localScroll.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*!
* jQuery.localScroll
* Copyright (c) 2007-2014 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
* Copyright (c) 2007-2015 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
* Licensed under MIT
* http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html
* @author Ariel Flesler
* @version 1.3.5
* @version 1.4.0
*/
;(function(plugin) {
// AMD Support
Expand Down Expand Up @@ -60,8 +60,8 @@
.end();

function filter() {// is this a link that points to an anchor and passes a possible filter ? href is checked to avoid a bug in FF.
return !!this.href && !!this.hash && this.href.replace(this.hash,'') == URI && (!settings.filter || $(this).is(settings.filter));
};
return !!this.href && !!this.hash && this.href.replace(this.hash,'') === URI && (!settings.filter || $(this).is(settings.filter));
}
};

// Not needed anymore, kept for backwards compatibility
Expand All @@ -71,20 +71,19 @@
var id = link.hash.slice(1),
elem = document.getElementById(id) || document.getElementsByName(id)[0];

if (!elem)
return;
if (!elem) return;

if (e)
e.preventDefault();
if (e) e.preventDefault();

var $target = $(settings.target);

if (settings.lock && $target.is(':animated') ||
settings.onBefore && settings.onBefore(e, elem, $target) === false)
return;

if (settings.stop)
$target._scrollable().stop(true); // remove all its animations
if (settings.stop) {
$target.stop(true); // remove all its animations
}

if (settings.hash) {
var attr = elem.id === id ? 'id' : 'name',
Expand All @@ -104,7 +103,7 @@
$target
.scrollTo(elem, settings) // do scroll
.trigger('notify.serialScroll',[elem]); // notify serialScroll about this change
};
}

// AMD requirement
return $localScroll;
Expand Down
6 changes: 3 additions & 3 deletions jquery.localScroll.min.js

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

30 changes: 0 additions & 30 deletions localScroll.jquery.json

This file was deleted.

Loading

0 comments on commit 1a55db8

Please sign in to comment.