Skip to content

Commit c881455

Browse files
author
Adam Girton
committed
Removed plugin call at beginning of script, cleaned up from jshint, added min file
Also added my name to authors.
1 parent f9de8ad commit c881455

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

hook.css

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
/**
22
* Hook
3-
* Version: 1.0
4-
* Author: Jordan Singer, Brandon Jacoby
3+
* Version: 1.1
4+
* Author: Jordan Singer, Brandon Jacoby, Adam Girton
55
* Copyright (c) 2013 - Hook. All rights reserved.
66
* http://www.usehook.com
77
*/
8-
9-
* {
10-
margin: 0;
11-
padding: 0;
12-
}
13-
14-
body {
15-
height: 2000px;
16-
}
178

189
/* 'customizable' declares that a property can be customized without breaking functionality */
1910
.hook * {
@@ -22,6 +13,7 @@ body {
2213
box-sizing: border-box;
2314
margin: 0 auto;
2415
}
16+
2517
.hook {
2618
display: none;
2719
/* customizable */ height: 85px;

hook.js

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
$(function () {
2-
$('#hook').hook();
3-
});
1+
/**
2+
* Hook
3+
* Version: 1.1
4+
* Author: Jordan Singer, Brandon Jacoby, Adam Girton
5+
* Copyright (c) 2013 - Hook. All rights reserved.
6+
* http://www.usehook.com
7+
*/
48

59
;(function ( $, window, document, undefined ) {
610
var win = $(this),
@@ -19,9 +23,8 @@ $(function () {
1923
return this.each(function() {
2024
var $this = $(this),
2125
settings = $this.data('hook');
22-
height = $this.height();
2326

24-
if(typeof(settings) == 'undefined') {
27+
if(typeof(settings) === 'undefined') {
2528

2629
var defaults = {
2730
reloadPage: true, // if false will reload element
@@ -80,7 +83,9 @@ $(function () {
8083
swipe = e.originalEvent.touches[0].pageY + lastY;
8184
st = $(this).scrollTop();
8285

83-
if(swipe < settings.swipeDistance) e.preventDefault();
86+
if(swipe < settings.swipeDistance) {
87+
e.preventDefault();
88+
}
8489

8590
if(swipe > settings.swipeDistance && lastY <= 40) {
8691
methods.onSwipe($this, settings);
@@ -113,15 +118,13 @@ $(function () {
113118
}
114119
},
115120

116-
onSwipe: function(el, settings, swipe) {
121+
onSwipe: function(el, settings) {
117122
if(st <= 0) {
118123
methods.reload(el, settings);
119124
}
120125
},
121126

122127
reload: function(el, settings) {
123-
var reloadEvent;
124-
125128
el.show();
126129
el.animate({
127130
"marginTop": "0px"
@@ -139,7 +142,7 @@ $(function () {
139142
}
140143
},
141144

142-
destroy: function(options) {
145+
destroy: function() {
143146
return $(this).each(function(){
144147
var $this = $(this);
145148

@@ -149,13 +152,13 @@ $(function () {
149152
}
150153
};
151154

152-
$.fn.hook = function (options ) {
155+
$.fn.hook = function () {
153156
var method = arguments[0];
154157

155158
if(methods[method]) {
156159
method = methods[method];
157160
arguments = Array.prototype.slice.call(arguments, 1);
158-
} else if (typeof(method) == 'object' || !method) {
161+
} else if (typeof(method) === 'object' || !method) {
159162
method = methods.init;
160163
} else {
161164
$.error( 'Method ' + method + ' does not exist on jQuery.pluginName' );

hook.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<div class="hook" id="hook"></div>
1010
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
1111
<script src="mousewheel.js"></script>
12-
<script src="hook.js"></script>
12+
<script src="hook.min.js"></script>
1313
</body>
1414
</html>

0 commit comments

Comments
 (0)