Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Prevent browser windows from moving/blinking on initial click of anch…
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsternberg committed May 15, 2015
1 parent 469dd46 commit 69c76ba
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
15 changes: 7 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ module.exports = function( grunt ) {
test: {
files: ['assets/js/test/**/*.js']
},

cssmin: {
options: {
banner: '/*! <%= pkg.title %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
Expand All @@ -75,24 +75,24 @@ module.exports = function( grunt ) {
},
minify: {
expand: true,

cwd: 'assets/css/src/',
src: ['hash-link-scroll-offset.css'],

dest: 'assets/css/',
ext: '.min.css'
}
},
watch: {

styles: {
files: ['assets/css/src/*.css'],
tasks: ['cssmin'],
options: {
debounceDelay: 500
}
},

scripts: {
files: ['assets/js/src/**/*.js', 'assets/js/vendor/**/*.js'],
tasks: ['jshint', 'concat', 'uglify'],
Expand All @@ -108,13 +108,12 @@ module.exports = function( grunt ) {
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');

grunt.loadNpmTasks('grunt-contrib-watch');

// Default task.

grunt.registerTask( 'default', ['jshint', 'concat', 'uglify', 'cssmin'] );


grunt.util.linefeed = '\n';
};
10 changes: 7 additions & 3 deletions assets/js/hash-link-scroll-offset.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Hash Link Scroll Offset - v0.1.0 - 2015-04-23
/*! Hash Link Scroll Offset - v0.1.0 - 2015-05-15
* http://webdevstudios.com
* Copyright (c) 2015; * Licensed GPLv2+ */
/*jslint browser: true */
Expand All @@ -13,8 +13,12 @@ window.Hash_Link_Scroll_Offset = (function(window, document, $, undefined){

app.offset = app.getOffset();

// cache jQuery selector results
app.$html_and_body = $('html, body');

// Handle clicking hash links
$( 'a[href^="#"]:not(.no-scroll)' ).on( 'click', function() {
$( 'a[href^="#"]:not(.no-scroll)' ).on( 'click', function( evt ) {
evt.preventDefault();
app.scrollToHash( this.hash );
});

Expand Down Expand Up @@ -53,7 +57,7 @@ window.Hash_Link_Scroll_Offset = (function(window, document, $, undefined){
return;
}

$('html, body').stop().animate({
app.$html_and_body.stop().animate({
'scrollTop': $element_to_scroll_to.offset().top - app.offset // scroll and offset
}, 900 );

Expand Down
4 changes: 2 additions & 2 deletions assets/js/hash-link-scroll-offset.min.js

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

8 changes: 6 additions & 2 deletions assets/js/src/hash-link-scroll-offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ window.Hash_Link_Scroll_Offset = (function(window, document, $, undefined){

app.offset = app.getOffset();

// cache jQuery selector results
app.$html_and_body = $('html, body');

// Handle clicking hash links
$( 'a[href^="#"]:not(.no-scroll)' ).on( 'click', function() {
$( 'a[href^="#"]:not(.no-scroll)' ).on( 'click', function( evt ) {
evt.preventDefault();
app.scrollToHash( this.hash );
});

Expand Down Expand Up @@ -58,7 +62,7 @@ window.Hash_Link_Scroll_Offset = (function(window, document, $, undefined){
return;
}

$('html, body').stop().animate({
app.$html_and_body.stop().animate({
'scrollTop': $element_to_scroll_to.offset().top - app.offset // scroll and offset
}, 900 );

Expand Down
2 changes: 1 addition & 1 deletion hash-link-scroll-offset.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Hash Link Scroll Offset
* Plugin URI: http://webdevstudios.com
* Description: Offset the scroll position of anchored links. Handy if you have a sticky header that covers linked material.
* Version: 0.1.2
* Version: 0.1.3
* Author: WebDevStudios
* Author URI: http://webdevstudios.com
* Donate link: http://webdevstudios.com
Expand Down
10 changes: 8 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: webdevstudios, jtsternberg
Donate link: http://webdevstudios.com
Tags:
Requires at least: 3.6.0
Tested up to: 3.6.0
Stable tag: 0.1.2
Tested up to: 4.2.2
Stable tag: 0.1.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -32,6 +32,9 @@ Use the `no-scroll` class on any hash links that are not meant to scroll to an a

== Changelog ==

= 0.1.3 =
* Prevent browser windows from moving/blinking on initial click of anchor link. Props [@ImBigWill](https://github.com/WebDevStudios/Hash-Link-Scroll-Offset/pull/9).

= 0.1.2 =
* Automatically compensate for admin bar. Props [@salcode](https://github.com/WebDevStudios/Hash-Link-Scroll-Offset/pull/5).

Expand All @@ -43,6 +46,9 @@ Use the `no-scroll` class on any hash links that are not meant to scroll to an a

== Upgrade Notice ==

= 0.1.3 =
* Prevent browser windows from moving/blinking on initial click of anchor link. Props [@ImBigWill](https://github.com/WebDevStudios/Hash-Link-Scroll-Offset/pull/9).

= 0.1.2 =
* Automatically compensate for admin bar. Props [@salcode](https://github.com/WebDevStudios/Hash-Link-Scroll-Offset/pull/5).

Expand Down

0 comments on commit 69c76ba

Please sign in to comment.