From 8e999c6ce520515af37cf39f31e17eda5dc48f29 Mon Sep 17 00:00:00 2001 From: Adam Girton Date: Tue, 16 Apr 2013 17:08:26 -0400 Subject: [PATCH 1/9] Started the rewrite to use a jQuery plugin with multiple options/ full configurable still need to add AJAX and css transitions --- hook.css | 24 +++++-- hook.js | 205 ++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 162 insertions(+), 67 deletions(-) diff --git a/hook.css b/hook.css index 5782407..bbc910f 100644 --- a/hook.css +++ b/hook.css @@ -5,12 +5,26 @@ * Copyright (c) 2013 - Hook. All rights reserved. * http://www.usehook.com */ + +* { + margin: 0; + padding: 0; +} + +body { + height: 2000px; +} + +#code { + position: fixed +} /* 'customizable' declares that a property can be customized without breaking functionality */ -#hook * { +.hook * { margin: 0 auto; } -#hook { +.hook { + display: none; /* customizable */ height: 85px; /* customizable */ background: url(hook-bg.png) repeat; /* customizable */ box-shadow: 0px -9px 5px -5px #999 inset; @@ -20,17 +34,17 @@ overflow: hidden; text-align: center; } -#hook span#hook-text { +.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 { +.hook-loader { padding: 10px 0; } -#hook .spinner { +.hook-spinner { display: block; /* customizable */ background: url(hook-spinner.gif) no-repeat center; /* customizable */ width: 32px; diff --git a/hook.js b/hook.js index 2c8dd10..2d1cc69 100644 --- a/hook.js +++ b/hook.js @@ -1,70 +1,151 @@ $(function () { - window.loadheight = $('#hook').height(); - window.hidden = $("#hook").animate("marginTop", "-" + loadheight + "px"); - window.visible = $("#hook").animate("marginTop", "0px"); - $("#hook").css("marginTop", "-" + loadheight + "px") + $('#hook').hook(); }); -$(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') + +;(function ( $, window, document, undefined ) { + var win = $(this), + st = win.scrollTop() || window.pageYOffset, + hasTouch = function() { + return !!('ontouchstart' in window) || !!('onmsgesturechange' in window); + }; + + win.scroll(function(){ + st = win.scrollTop(); + }); + + var methods = { + + init: function(options) { + + return this.each(function() { + var $this = $(this), + settings = $this.data('hook'); + height = $this.height(); + + if(typeof(settings) == 'undefined') { + + var defaults = { + reloadPage: true, // if false will reload element + dynamic: true, // if false Hook elements already there + textRequired: false, // will input loader text if true + swipeDistance: 50, // swipe distance for loader to show on touch devices + loaderClass: 'hook-loader', + spinnerClass: 'hook-spinner', + loaderTextClass: 'hook-text', + loaderText: 'Reloading...' + }; + + settings = $.extend({}, defaults, options); + + $this.data('hook', settings); + } else { + + settings = $.extend({}, settings, options); + } + + if(settings.dynamic === true) { + var loaderElem = '
'; + loaderElem += '
'; + loaderElem += '
'; + var spinnerTextElem = '' + settings.loaderText + ''; + + $this + .append(loaderElem); + + if (settings.textRequired === true) { + $this.append(spinnerTextElem); + } + + } + + if(!hasTouch()) { + win.bind('mousewheel', function(event, delta) { + methods.onScroll($this, settings, delta); + }); + } else { + var lastY = 0, + swipe = 0; + win.on('touchstart', function(e){ + lastY = e.originalEvent.touches[0].pageY; + }); + + win.on('touchmove', function(e) { + swipe = e.originalEvent.touches[0].pageY + lastY; + st = $(this).scrollTop(); + + if(swipe < settings.swipeDistance) { + e.preventDefault(); + } + + if(swipe > settings.swipeDistance && lastY <= 40) { + methods.onSwipe($this, settings); + } + }); + + win.on('touchend', function(){ + swipe = 0; + }); + } + + }); + }, + + onScroll: function(el, settings,delta) { + if(delta > 10 && st <= 0) + { + methods.reload(el, settings); } - } - }) -}); + }, + + onSwipe: function(el, settings, swipe) { + if(st <= 0) { + methods.reload(el, settings); + } + }, + + reload: function(el, settings) { + var reloadEvent; + + if(settings.reloadPage === false) { + reloadEvent = new Event('reloaded'); + window.dispatchEvent(reloadEvent); + } else { -//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" + el.show(); + el.animate({ + "marginTop": "0px" + }, 200); + el.delay(500).slideUp(200, function () { + window.location.reload(true); + }); + } + }, + + destroy: function(options) { + return $(this).each(function(){ + var $this = $(this); + + $this.empty(); + $this.removeData('hook'); + }); } }; - 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) + + $.fn.hook = function (options ) { + var method = arguments[0]; + + if(methods[method]) { + method = methods[method]; + arguments = Array.prototype.slice.call(arguments, 1); + } else if (typeof(method) == 'object' || !method) { + method = methods.init; + } else { + $.error( 'Method ' + method + ' does not exist on jQuery.pluginName' ); + return this; } - 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 - } -})(); \ No newline at end of file + + return method.apply(this, arguments); + }; + +})( jQuery, window, document ); \ No newline at end of file From c4ca37a842d77388633b87b7f46fd43aaff3c435 Mon Sep 17 00:00:00 2001 From: Adam Girton Date: Tue, 16 Apr 2013 22:07:46 -0400 Subject: [PATCH 2/9] Added mousewheel as a dependency. Moved the if statement as a call back to the slideUp callback Will be changing this so can use css3 transitions/animations instead of jQuery animation. Still need to work out the bug where callback is firing multiple times. Firefox does not like to reload page until mouse has scrolled down first. May use mouse movements in addition to touch and mousewheel --- hook.js | 36 ++++++---------- index.html | 14 ++++++ mousewheel.js | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 22 deletions(-) create mode 100644 index.html create mode 100644 mousewheel.js diff --git a/hook.js b/hook.js index 2d1cc69..d3af6aa 100644 --- a/hook.js +++ b/hook.js @@ -9,11 +9,7 @@ $(function () { return !!('ontouchstart' in window) || !!('onmsgesturechange' in window); }; - win.scroll(function(){ - st = win.scrollTop(); - }); - - var methods = { + var methods = { init: function(options) { @@ -32,7 +28,8 @@ $(function () { loaderClass: 'hook-loader', spinnerClass: 'hook-spinner', loaderTextClass: 'hook-text', - loaderText: 'Reloading...' + loaderText: 'Reloading...', + reloadEl: function() {} }; settings = $.extend({}, defaults, options); @@ -55,12 +52,13 @@ $(function () { if (settings.textRequired === true) { $this.append(spinnerTextElem); } - } if(!hasTouch()) { - win.bind('mousewheel', function(event, delta) { - methods.onScroll($this, settings, delta); + win.on('mousewheel', function(event, delta) { + if(delta >= 100 && st <= 0) { + methods.onScroll($this, settings, delta); + } }); } else { var lastY = 0, @@ -90,11 +88,8 @@ $(function () { }); }, - onScroll: function(el, settings,delta) { - if(delta > 10 && st <= 0) - { - methods.reload(el, settings); - } + onScroll: function(el, settings) { + methods.reload(el, settings); }, onSwipe: function(el, settings, swipe) { @@ -106,20 +101,17 @@ $(function () { reload: function(el, settings) { var reloadEvent; - if(settings.reloadPage === false) { - reloadEvent = new Event('reloaded'); - window.dispatchEvent(reloadEvent); - - } else { - el.show(); el.animate({ "marginTop": "0px" }, 200); el.delay(500).slideUp(200, function () { - window.location.reload(true); + if(settings.reloadPage === true) { + window.location.reload(true); + } else { + settings.reloadEl(); + } }); - } }, destroy: function(options) { diff --git a/index.html b/index.html new file mode 100644 index 0000000..615e4db --- /dev/null +++ b/index.html @@ -0,0 +1,14 @@ + + + + + Hook Fork + + + +
+ + + + + \ No newline at end of file diff --git a/mousewheel.js b/mousewheel.js new file mode 100644 index 0000000..75118a2 --- /dev/null +++ b/mousewheel.js @@ -0,0 +1,117 @@ +/*! Copyright (c) 2013 Brandon Aaron (http://brandonaaron.net) + * Licensed under the MIT License (LICENSE.txt). + * + * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. + * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. + * Thanks to: Seamus Leahy for adding deltaX and deltaY + * + * Version: 3.1.3 + * + * Requires: 1.2.2+ + */ + +(function (factory) { + if ( typeof define === 'function' && define.amd ) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else if (typeof exports === 'object') { + // Node/CommonJS style for Browserify + module.exports = factory; + } else { + // Browser globals + factory(jQuery); + } +}(function ($) { + + var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll']; + var toBind = 'onwheel' in document || document.documentMode >= 9 ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll']; + var lowestDelta, lowestDeltaXY; + + if ( $.event.fixHooks ) { + for ( var i = toFix.length; i; ) { + $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks; + } + } + + $.event.special.mousewheel = { + setup: function() { + if ( this.addEventListener ) { + for ( var i = toBind.length; i; ) { + this.addEventListener( toBind[--i], handler, false ); + } + } else { + this.onmousewheel = handler; + } + }, + + teardown: function() { + if ( this.removeEventListener ) { + for ( var i = toBind.length; i; ) { + this.removeEventListener( toBind[--i], handler, false ); + } + } else { + this.onmousewheel = null; + } + } + }; + + $.fn.extend({ + mousewheel: function(fn) { + return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); + }, + + unmousewheel: function(fn) { + return this.unbind("mousewheel", fn); + } + }); + + + function handler(event) { + var orgEvent = event || window.event, + args = [].slice.call(arguments, 1), + delta = 0, + deltaX = 0, + deltaY = 0, + absDelta = 0, + absDeltaXY = 0, + fn; + event = $.event.fix(orgEvent); + event.type = "mousewheel"; + + // Old school scrollwheel delta + if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta; } + if ( orgEvent.detail ) { delta = orgEvent.detail * -1; } + + // New school wheel delta (wheel event) + if ( orgEvent.deltaY ) { + deltaY = orgEvent.deltaY * -1; + delta = deltaY; + } + if ( orgEvent.deltaX ) { + deltaX = orgEvent.deltaX; + delta = deltaX * -1; + } + + // Webkit + if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY; } + if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = orgEvent.wheelDeltaX * -1; } + + // Look for lowest delta to normalize the delta values + absDelta = Math.abs(delta); + if ( !lowestDelta || absDelta < lowestDelta ) { lowestDelta = absDelta; } + absDeltaXY = Math.max(Math.abs(deltaY), Math.abs(deltaX)); + if ( !lowestDeltaXY || absDeltaXY < lowestDeltaXY ) { lowestDeltaXY = absDeltaXY; } + + // Get a whole value for the deltas + fn = delta > 0 ? 'floor' : 'ceil'; + delta = Math[fn](delta / lowestDelta); + deltaX = Math[fn](deltaX / lowestDeltaXY); + deltaY = Math[fn](deltaY / lowestDeltaXY); + + // Add event and delta to the front of the arguments + args.unshift(event, delta, deltaX, deltaY); + + return ($.event.dispatch || $.event.handle).apply(this, args); + } + +})); \ No newline at end of file From 0ec393942e88bb3da133fa74963cb4237b288197 Mon Sep 17 00:00:00 2001 From: agirton Date: Tue, 16 Apr 2013 23:19:43 -0300 Subject: [PATCH 3/9] Add README.md --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..38a0d20 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +Hook.js +======= + +Pull to refresh. For the web. This rewrite is a work in progress and has only been tested on the latest Safari, Chrome, and Firefox. There are a few bugs that I'm currently working through with Firefox. + +There are 9 settings and 1 callback. Which are the following; + +reloadPage: default is true, if false will reload element (note must also have reloadEl callback), +dynamic: default is true, if false you will need your own html, +textRequired: default is false, if true the dynamic text HTML will be added, +swipeDistance: default is 50, the amount of swipe distance on touch devices to fire reload, +loaderClass: default is hook-loader, +spinnerClass: default is hook-spinner, +loaderTextClass: default is hook-text, +loaderText: default is 'Reloading..' is only set when you set 'textRequired' +reloadEl: callback + +Outstanding issues: +Callback called more than once. + +ToDo's: +Convert from jQuery animate to css3 transitions for browsers that support it. From 9a56f7497cbef47ee0083cbd47a9f14e1dcc07d2 Mon Sep 17 00:00:00 2001 From: Adam Girton Date: Tue, 16 Apr 2013 22:26:54 -0400 Subject: [PATCH 4/9] Cleaned up README --- README.md | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 38a0d20..bec785f 100644 --- a/README.md +++ b/README.md @@ -3,20 +3,19 @@ Hook.js Pull to refresh. For the web. This rewrite is a work in progress and has only been tested on the latest Safari, Chrome, and Firefox. There are a few bugs that I'm currently working through with Firefox. -There are 9 settings and 1 callback. Which are the following; +##There are 9 settings and 1 callback. Which are the following; +* reloadPage: default is true, if false will reload element (note must also have reloadEl callback), +* dynamic: default is true, if false you will need your own html, +* textRequired: default is false, if true the dynamic text HTML will be added, +* swipeDistance: default is 50, the amount of swipe distance on touch devices to fire reload, +* loaderClass: default is hook-loader, +* spinnerClass: default is hook-spinner, +* loaderTextClass: default is hook-text, +* loaderText: default is 'Reloading..' is only set when you set 'textRequired' +* reloadEl: callback -reloadPage: default is true, if false will reload element (note must also have reloadEl callback), -dynamic: default is true, if false you will need your own html, -textRequired: default is false, if true the dynamic text HTML will be added, -swipeDistance: default is 50, the amount of swipe distance on touch devices to fire reload, -loaderClass: default is hook-loader, -spinnerClass: default is hook-spinner, -loaderTextClass: default is hook-text, -loaderText: default is 'Reloading..' is only set when you set 'textRequired' -reloadEl: callback +##Outstanding issues: +* Callback called more than once. -Outstanding issues: -Callback called more than once. - -ToDo's: -Convert from jQuery animate to css3 transitions for browsers that support it. +##ToDo's: +* Convert from jQuery animate to css3 transitions for browsers that support it. From e4c3122f7552120b38e1cb374b8095b4990a13fd Mon Sep 17 00:00:00 2001 From: Adam Girton Date: Tue, 16 Apr 2013 22:33:18 -0400 Subject: [PATCH 5/9] Added dependency and Examples to readme --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index bec785f..65c861e 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ Hook.js Pull to refresh. For the web. This rewrite is a work in progress and has only been tested on the latest Safari, Chrome, and Firefox. There are a few bugs that I'm currently working through with Firefox. +##Dependency +* Needs mousewheel.js, however will most likely change this to an option in future commits. + ##There are 9 settings and 1 callback. Which are the following; * reloadPage: default is true, if false will reload element (note must also have reloadEl callback), * dynamic: default is true, if false you will need your own html, @@ -19,3 +22,17 @@ Pull to refresh. For the web. This rewrite is a work in progress and has only be ##ToDo's: * Convert from jQuery animate to css3 transitions for browsers that support it. + +##Examples: +```` JS +// No options +$('#hook').hook(); + +// Callback +$('#hook').hook({ + reloadPage: false, + reloadEl: function(){ + console.log('Hello World!); + } +}); +```` \ No newline at end of file From f161a0edda7936c8ae7734367f25aa3c112f23cd Mon Sep 17 00:00:00 2001 From: Adam Girton Date: Tue, 16 Apr 2013 23:09:52 -0400 Subject: [PATCH 6/9] Checking a boolean each time mousewheel event is fired. Now callback is only fired once. --- hook.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/hook.js b/hook.js index d3af6aa..ef339f3 100644 --- a/hook.js +++ b/hook.js @@ -5,10 +5,13 @@ $(function () { ;(function ( $, window, document, undefined ) { var win = $(this), st = win.scrollTop() || window.pageYOffset, - hasTouch = function() { + called = false; + + var hasTouch = function() { return !!('ontouchstart' in window) || !!('onmsgesturechange' in window); }; + var methods = { init: function(options) { @@ -56,9 +59,13 @@ $(function () { if(!hasTouch()) { win.on('mousewheel', function(event, delta) { - if(delta >= 100 && st <= 0) { - methods.onScroll($this, settings, delta); - } + if(delta >= 150 && st <= 0) { + if(called === false) { + methods.onScroll($this, settings, delta); + + called = true; + } + } }); } else { var lastY = 0, @@ -106,12 +113,16 @@ $(function () { "marginTop": "0px" }, 200); el.delay(500).slideUp(200, function () { - if(settings.reloadPage === true) { + if(settings.reloadPage) { window.location.reload(true); - } else { - settings.reloadEl(); } + + called = false; }); + + if(!settings.reloadPage) { + settings.reloadEl(); + } }, destroy: function(options) { From 763ac22b62b9247f3a92a10fc1c9efed2f60282f Mon Sep 17 00:00:00 2001 From: Adam Girton Date: Wed, 17 Apr 2013 00:02:14 -0400 Subject: [PATCH 7/9] Added class to element when text is there. Updated readme for current know issues. Updated assets to use hook as spinner, using css3 animations to spin it. --- .gitignore | 2 ++ README.md | 2 +- hook-bgs.png | Bin 0 -> 5230 bytes hook-spinner.png | Bin 0 -> 1560 bytes hook-spinner@2x.png | Bin 0 -> 2190 bytes hook.css | 76 ++++++++++++++++++++++++++++++++++++++------ hook.js | 5 +-- 7 files changed, 72 insertions(+), 13 deletions(-) create mode 100644 .gitignore create mode 100644 hook-bgs.png create mode 100644 hook-spinner.png create mode 100644 hook-spinner@2x.png diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bea433 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +.DS_Store diff --git a/README.md b/README.md index 65c861e..e7b807a 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Pull to refresh. For the web. This rewrite is a work in progress and has only be * reloadEl: callback ##Outstanding issues: -* Callback called more than once. +* Firefox reload only appearing after first scrolling down. ##ToDo's: * Convert from jQuery animate to css3 transitions for browsers that support it. diff --git a/hook-bgs.png b/hook-bgs.png new file mode 100644 index 0000000000000000000000000000000000000000..9705e9cd21bcfe9c7568d57730fdebe390dd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@;fU{Z`;ldMvTCS@g{~J&@yF=IFfvf z>L+_Ky0Ht>cAOv@S*=!H>z4&3elI=*`&Wd4kJJwPR;oKx@ZYtvZ)G`?8K=3s_Ode2 z1)#e(0W2Uf^pBlo<7}yD{$i{XhrIsWo`Q5>rUFw$NX^n_4)3=I@GxHyB6uY2FM!6-O@9*Y~}5e20ogYeE$9p3H4SP8B*s|Z!VLExb?Dm+QZ}? zU$r_C-q~YG%r1+_Cy}!$9L1N!eGD3ima0yTC%QqY3<+RdDZECME2-(hA%Xe?<3EFr#v^rfzN-!Dr)qwzG3Bl;{K)>ycdWLgvX4K# zOn+EGWp|IZvH2w`bNKz|rsegKgR|;x!>U2)#ZLDbb6S^NVuYy+QI`5Vndxj^2u$Pj zIkj(8PFaM0kz-zH?zPf$V?Gqp=k(hU)ByFOO}x7HfWVHskkbfj7E|@P)+@*_+Bm}7 scFebF)%}|pmU*>8c0a>jRZhS8UIx{Z@1a{C{=E1~@@nvES&QKR0kY+{p8x;= literal 0 HcmV?d00001 diff --git a/hook-spinner.png b/hook-spinner.png new file mode 100644 index 0000000000000000000000000000000000000000..09fbb94be4cfbcc17ba763b0afc775161b8501ce GIT binary patch literal 1560 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%qp275hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|81#=KlDb#X~hD#E>34K5C;EJ)Q4 zN-fSWElLJPT$(b-ssbzLqSVBa{GyQj{2W*)24v)y-fM)1rW~Nw~Ivbf-IJ&u7x*3}q8oC-;I6FIAy16+SxjDJH zIT|{{^t$9Hm*%GCmB93-AoRN7)C)=sxdlL*T~doO%TiO^it=+6z@E0s#O)TK{kYr$ z(VK$XEiO3q>H{644~kl(sD=pv(+`LVPq;u1Jn5(A0n>XCFk!3yU&zV8z|`gG;uunK zYs>W0*&>bt?d8|Sk6rCpaq;MnYZV4<0Ii|4Zb}H+c zcF)V1GGgb9cKGjiKGLUY_<3O>b2a00Y>L)nv_xuxBs2q zz~tJ;F~i`TE@yqG{|5eJvAs$Uc7BxgOSE!15~s1tYt!6kEx&Su)0);aB`I7>-oG%z zWsbjR!v%)*f3Li;w(e<=jF`TtZEC%Iev#R= z#q0q(jEC5EyjU^o@Vl1j3srOelWO;wLz6z+U_H^}gS?83{1OQf*PWb=; literal 0 HcmV?d00001 diff --git a/hook-spinner@2x.png b/hook-spinner@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..1c215452c0df97e494de44a1b88efcfafa9c8d88 GIT binary patch literal 2190 zcmaJ@X;@QN8oulrfw7>~Qo#@!6>3%pCNTjMl0bljEg~*eVse21Np2Q4Q3wj-0xICN zq96kDAg&D}ZIoCOEGnZQAa00=0>e@&P!*)2_D03d4`=Rk?>*;y&-cFH`z=4t?ohtJ z9l{9#0Dv7gfE5m}t4!Z4YxsXsqUeT~uhi@)b%Z=dog!3%07ER_3?jKwVJsL93dL!P zCXfaI7T-t&QR*mOFjXX%VudCjY^oH3(Evd6O@)M_1W=9K48}@ibku15WfW2(rlZ!7 zcz7P<2gXSPwkW}fEqsA!OM-|ZM)~?6X{l70Knkjb$W&>fOhrwlqu%pU;l0U>Lm}V0 zs1xX@52B)Yp-4Zu5=4@)o){6HKtOtXV+md)Z*RhKBoR*_;_&e6jUjkZN#0cA3gpKJ z1xHhgW2oUQ&c|5riH?d>t05{5my(i#P4UFam9aPig+eiL5Q!Mr1EWflsfDQ+naXX3 zfd#5WN(rQv$Yn?qqj0l4Nliz=N%Xt^Kc7&zRu(F>OB$E`0bj`k)M+cO^X7fy2x` z0I&kMEQTPpv!ggOE^_t4Yqz==#hs-@xPop7(wQe^hn&h?bER*AHeZ%P8<2DE<~+Nw zp~dBcHiC|J-@6=-YAe2iQB)R%Pq>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+P{ z?=RMf^knWqa<|Qu#0!++8sI!z2VGpO?e1&LtHy?eJpCpfo#{Og({_)-?+icppQX1Q z_XYx&`^T@fdzSEvmxnLqrTGX45%lkl)!#UD!n353?()**d8oz=D9?&p`H(hfx_JOx LHlKBt8NK~4Zkc~` literal 0 HcmV?d00001 diff --git a/hook.css b/hook.css index bbc910f..c440b34 100644 --- a/hook.css +++ b/hook.css @@ -14,20 +14,19 @@ body { height: 2000px; } - -#code { - position: fixed -} /* 'customizable' declares that a property can be customized without breaking functionality */ .hook * { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; margin: 0 auto; } .hook { display: none; /* customizable */ height: 85px; - /* customizable */ background: url(hook-bg.png) repeat; - /* customizable */ box-shadow: 0px -9px 5px -5px #999 inset; + /* customizable */ background: url(hook-bgs.png) repeat; + /* customizable */ box-shadow: 0 -8px 5px -5px #999 inset; clear: both; position: relative; width: 100%; @@ -37,16 +36,73 @@ body { .hook-text { /* customizable */ font-size: 14px; /* customizable */ font-family: Arial, Helvetica, sans-serif; - /* customizable */ color: #999; + /* customizable */ color: #666; /* customizable */ font-weight: normal; - /* customizable */ text-shadow: 0px 1px #fff; + /* customizable */ text-shadow: 0 1px #fff; } .hook-loader { - padding: 10px 0; + padding: 25px 0; } .hook-spinner { display: block; - /* customizable */ background: url(hook-spinner.gif) no-repeat center; + /* customizable */ background: url(hook-spinner.png) no-repeat center; /* customizable */ width: 32px; /* customizable */ height: 32px; + -webkit-animation: spin 1s linear infinite both; + -moz-animation: spin 1s linear infinite both; + -o-animation: spin 1s linear infinite both; + animation: spin 1s linear infinite both; +} +.hook-with-text .hook-loader{ + padding: 10px 0; +} + +@media +only screen and (-webkit-min-device-pixel-ratio: 2), +only screen and ( min--moz-device-pixel-ratio: 2), +only screen and ( -o-min-device-pixel-ratio: 2/1), +only screen and ( min-device-pixel-ratio: 2), +only screen and ( min-resolution: 192dpi), +only screen and ( min-resolution: 2dppx) { + + .hook-spinner { + background: url(hook-spinner@2x.png) no-repeat center; + background-size: 32px 32px; + } +} + +@-webkit-keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(360deg); + } +} + +@-moz-keyframes spin { + 0% { + -moz-transform: rotate(0deg); + } + 100% { + -moz-transform: rotate(360deg); + } +} + +@-o-keyframes spin { + 0% { + -o-transform: rotate(0deg); + } + 100% { + -o-transform: rotate(360deg); + } +} + +@keyframes spin { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } } \ No newline at end of file diff --git a/hook.js b/hook.js index ef339f3..2b140a0 100644 --- a/hook.js +++ b/hook.js @@ -47,13 +47,14 @@ $(function () { var loaderElem = '
'; loaderElem += '
'; loaderElem += '
'; - var spinnerTextElem = '' + settings.loaderText + ''; + var spinnerTextElem = '' + settings.loaderText + ''; $this .append(loaderElem); if (settings.textRequired === true) { - $this.append(spinnerTextElem); + $this.addClass('hook-with-text'); + $this.append(spinnerTextElem); } } From f9de8ada39ea6b5961a1e0b3b86f20427502c2c0 Mon Sep 17 00:00:00 2001 From: Adam Girton Date: Wed, 17 Apr 2013 00:55:59 -0400 Subject: [PATCH 8/9] scroll wheel now optional. set to false by default --- hook.js | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/hook.js b/hook.js index 2b140a0..6bb9005 100644 --- a/hook.js +++ b/hook.js @@ -27,6 +27,7 @@ $(function () { reloadPage: true, // if false will reload element dynamic: true, // if false Hook elements already there textRequired: false, // will input loader text if true + scrollWheelSelected: false, // will use scroll wheel events swipeDistance: 50, // swipe distance for loader to show on touch devices loaderClass: 'hook-loader', spinnerClass: 'hook-spinner', @@ -59,15 +60,15 @@ $(function () { } if(!hasTouch()) { - win.on('mousewheel', function(event, delta) { - if(delta >= 150 && st <= 0) { - if(called === false) { - methods.onScroll($this, settings, delta); - - called = true; - } - } - }); + if(settings.scrollWheelSelected === true){ + win.on('mousewheel', function(event, delta) { + methods.onScroll($this, settings, delta); + }); + } else { + win.on('scroll', function() { + methods.onScroll($this, settings); + }); + } } else { var lastY = 0, swipe = 0; @@ -79,9 +80,7 @@ $(function () { swipe = e.originalEvent.touches[0].pageY + lastY; st = $(this).scrollTop(); - if(swipe < settings.swipeDistance) { - e.preventDefault(); - } + if(swipe < settings.swipeDistance) e.preventDefault(); if(swipe > settings.swipeDistance && lastY <= 40) { methods.onSwipe($this, settings); @@ -96,8 +95,22 @@ $(function () { }); }, - onScroll: function(el, settings) { - methods.reload(el, settings); + onScroll: function(el, settings, delta) { + st = win.scrollTop(); + + if(settings.scrollWheelSelected === true && (delta >= 150 && st <= 0)) { + if(called === false) { + methods.reload(el, settings); + called = true; + } + } + + if(settings.scrollWheelSelected === false && st <= 0) { + if(called === false) { + methods.reload(el, settings); + called = true; + } + } }, onSwipe: function(el, settings, swipe) { From c8814553a5a3d089298d0c63e7d31cfeb9615f6c Mon Sep 17 00:00:00 2001 From: Adam Girton Date: Thu, 18 Apr 2013 22:51:59 -0400 Subject: [PATCH 9/9] Removed plugin call at beginning of script, cleaned up from jshint, added min file Also added my name to authors. --- hook.css | 14 +++----------- hook.js | 27 +++++++++++++++------------ hook.min.js | 1 + index.html | 2 +- 4 files changed, 20 insertions(+), 24 deletions(-) create mode 100644 hook.min.js diff --git a/hook.css b/hook.css index c440b34..b7ff935 100644 --- a/hook.css +++ b/hook.css @@ -1,19 +1,10 @@ /** * Hook - * Version: 1.0 - * Author: Jordan Singer, Brandon Jacoby + * Version: 1.1 + * Author: Jordan Singer, Brandon Jacoby, Adam Girton * Copyright (c) 2013 - Hook. All rights reserved. * http://www.usehook.com */ - -* { - margin: 0; - padding: 0; -} - -body { - height: 2000px; -} /* 'customizable' declares that a property can be customized without breaking functionality */ .hook * { @@ -22,6 +13,7 @@ body { box-sizing: border-box; margin: 0 auto; } + .hook { display: none; /* customizable */ height: 85px; diff --git a/hook.js b/hook.js index 6bb9005..28ee909 100644 --- a/hook.js +++ b/hook.js @@ -1,6 +1,10 @@ -$(function () { - $('#hook').hook(); -}); +/** + * Hook + * Version: 1.1 + * Author: Jordan Singer, Brandon Jacoby, Adam Girton + * Copyright (c) 2013 - Hook. All rights reserved. + * http://www.usehook.com + */ ;(function ( $, window, document, undefined ) { var win = $(this), @@ -19,9 +23,8 @@ $(function () { return this.each(function() { var $this = $(this), settings = $this.data('hook'); - height = $this.height(); - if(typeof(settings) == 'undefined') { + if(typeof(settings) === 'undefined') { var defaults = { reloadPage: true, // if false will reload element @@ -80,7 +83,9 @@ $(function () { swipe = e.originalEvent.touches[0].pageY + lastY; st = $(this).scrollTop(); - if(swipe < settings.swipeDistance) e.preventDefault(); + if(swipe < settings.swipeDistance) { + e.preventDefault(); + } if(swipe > settings.swipeDistance && lastY <= 40) { methods.onSwipe($this, settings); @@ -113,15 +118,13 @@ $(function () { } }, - onSwipe: function(el, settings, swipe) { + onSwipe: function(el, settings) { if(st <= 0) { methods.reload(el, settings); } }, reload: function(el, settings) { - var reloadEvent; - el.show(); el.animate({ "marginTop": "0px" @@ -139,7 +142,7 @@ $(function () { } }, - destroy: function(options) { + destroy: function() { return $(this).each(function(){ var $this = $(this); @@ -149,13 +152,13 @@ $(function () { } }; - $.fn.hook = function (options ) { + $.fn.hook = function () { var method = arguments[0]; if(methods[method]) { method = methods[method]; arguments = Array.prototype.slice.call(arguments, 1); - } else if (typeof(method) == 'object' || !method) { + } else if (typeof(method) === 'object' || !method) { method = methods.init; } else { $.error( 'Method ' + method + ' does not exist on jQuery.pluginName' ); diff --git a/hook.min.js b/hook.min.js new file mode 100644 index 0000000..0ebbd2e --- /dev/null +++ b/hook.min.js @@ -0,0 +1 @@ +(function(c,f,g,b){var d=c(this),i=d.scrollTop()||f.pageYOffset,h=false;var e=function(){return !!("ontouchstart" in f)||!!("onmsgesturechange" in f)};var a={init:function(j){return this.each(function(){var q=c(this),m=q.data("hook");if(typeof(m)==="undefined"){var p={reloadPage:true,dynamic:true,textRequired:false,scrollWheelSelected:false,swipeDistance:50,loaderClass:"hook-loader",spinnerClass:"hook-spinner",loaderTextClass:"hook-text",loaderText:"Reloading...",reloadEl:function(){}};m=c.extend({},p,j);q.data("hook",m)}else{m=c.extend({},m,j)}if(m.dynamic===true){var k="
";k+="
";k+="
";var o=""+m.loaderText+"";q.append(k);if(m.textRequired===true){q.addClass("hook-with-text");q.append(o)}}if(!e()){if(m.scrollWheelSelected===true){d.on("mousewheel",function(r,s){a.onScroll(q,m,s)})}else{d.on("scroll",function(){a.onScroll(q,m)})}}else{var n=0,l=0;d.on("touchstart",function(r){n=r.originalEvent.touches[0].pageY});d.on("touchmove",function(r){l=r.originalEvent.touches[0].pageY+n;i=c(this).scrollTop();if(lm.swipeDistance&&n<=40){a.onSwipe(q,m)}});d.on("touchend",function(){l=0})}})},onScroll:function(k,j,l){i=d.scrollTop();if(j.scrollWheelSelected===true&&(l>=150&&i<=0)){if(h===false){a.reload(k,j);h=true}}if(j.scrollWheelSelected===false&&i<=0){if(h===false){a.reload(k,j);h=true}}},onSwipe:function(k,j){if(i<=0){a.reload(k,j)}},reload:function(k,j){k.show();k.animate({marginTop:"0px"},200);k.delay(500).slideUp(200,function(){if(j.reloadPage){f.location.reload(true)}h=false});if(!j.reloadPage){j.reloadEl()}},destroy:function(){return c(this).each(function(){var j=c(this);j.empty();j.removeData("hook")})}};c.fn.hook=function(){var j=arguments[0];if(a[j]){j=a[j];arguments=Array.prototype.slice.call(arguments,1)}else{if(typeof(j)==="object"||!j){j=a.init}else{c.error("Method "+j+" does not exist on jQuery.pluginName");return this}}return j.apply(this,arguments)}})(jQuery,window,document); \ No newline at end of file diff --git a/index.html b/index.html index 615e4db..9973975 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,6 @@
- + \ No newline at end of file