Skip to content

Commit

Permalink
Pull to refresh. For the web.
Browse files Browse the repository at this point in the history
  • Loading branch information
jordansinger committed Mar 1, 2013
0 parents commit 2863fcf
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
Binary file added hook-bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hook-spinner.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions hook.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Hook
* Version: 1.0
* Author: Jordan Singer, Brandon Jacoby
* Copyright (c) 2013 - Hook. All rights reserved.
* http://www.usehook.com
*/

/* 'customizable' declares that a property can be customized without breaking functionality */
#hook * {
margin: 0 auto;
}
#hook {
/* customizable */ height: 85px;
/* customizable */ background: url(hook-bg.png) repeat;
/* customizable */ box-shadow: 0px -9px 5px -5px #999 inset;
clear: both;
position: relative;
width: 100%;
overflow: hidden;
text-align: center;
}
#hook span#hook-text {
/* customizable */ font-size: 14px;
/* customizable */ font-family: Arial, Helvetica, sans-serif;
/* customizable */ color: #999;
/* customizable */ font-weight: normal;
/* customizable */ text-shadow: 0px 1px #fff;
}
#hook #loader {
padding: 10px 0;
}
#hook .spinner {
display: block;
/* customizable */ background: url(hook-spinner.gif) no-repeat center;
/* customizable */ width: 32px;
/* customizable */ height: 32px;
}
70 changes: 70 additions & 0 deletions hook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
$(function () {
window.loadheight = $('#hook').height();
window.hidden = $("#hook").animate("marginTop", "-" + loadheight + "px");
window.visible = $("#hook").animate("marginTop", "0px");
$("#hook").css("marginTop", "-" + loadheight + "px")
});
$(function hook() {
var loadheight = $('#hook').height();
$(window).scroll(function (event) {
var st = $(window).scrollTop();
if (st <= 0) {
$("#hook").animate({
"marginTop": "0px"
}, 200);
$("#hook").delay(500).slideUp(200, function () {
window.location.reload()
})
}
if ($.browser.webkit) {
if (st == 0) {
$('body').css('overflow', 'hidden')
}
}
})
});


//Browser detection, unsupported in jQuery latest.
(function () {
var matched, browser;
jQuery.uaMatch = function (ua) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || /(webkit)[ \/]([\w.]+)/.exec(ua) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || /(msie) ([\w.]+)/.exec(ua) || ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || [];
return {
browser: match[1] || "",
version: match[2] || "0"
}
};
matched = jQuery.uaMatch(navigator.userAgent);
browser = {};
if (matched.browser) {
browser[matched.browser] = true;
browser.version = matched.version
}
if (browser.chrome) {
browser.webkit = true
} else if (browser.webkit) {
browser.safari = true
}
jQuery.browser = browser;
jQuery.sub = function () {
function jQuerySub(selector, context) {
return new jQuerySub.fn.init(selector, context)
}
jQuery.extend(true, jQuerySub, this);
jQuerySub.superclass = this;
jQuerySub.fn = jQuerySub.prototype = this();
jQuerySub.fn.constructor = jQuerySub;
jQuerySub.sub = this.sub;
jQuerySub.fn.init = function init(selector, context) {
if (context && context instanceof jQuery && !(context instanceof jQuerySub)) {
context = jQuerySub(context)
}
return jQuery.fn.init.call(this, selector, context, rootjQuerySub)
};
jQuerySub.fn.init.prototype = jQuerySub.fn;
var rootjQuerySub = jQuerySub(document);
return jQuerySub
}
})();

0 comments on commit 2863fcf

Please sign in to comment.