Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:christophercliff/sausage

Conflicts:
	jquery.sausage.js
  • Loading branch information...
commit 2a038a5c228a1a67ef7f4278a8509f7c862038e8 2 parents fba137c + fec9b4c
@christophercliff authored
Showing with 51 additions and 13 deletions.
  1. +50 −13 jquery.sausage.js
  2. +1 −0  lib/sausage.css
View
63 jquery.sausage.js
@@ -52,7 +52,7 @@
//
//
- // ## ._create()
+ // ## `._create()`
//
//
_create: function () {
@@ -78,7 +78,7 @@
return;
},
- // ## ._init()
+ // ## `._init()`
//
//
_init: function () {
@@ -111,7 +111,7 @@
return;
},
- // ## ._events()
+ // ## `._events()`
//
//
_events: function () {
@@ -120,13 +120,13 @@
self.hasScrolled = false;
- $(window)
- .resize(function(){
+ self.$outer
+ .bind('resize.sausage', function(){
self.draw();
})
- .scroll(function(e){
+ .bind('scroll.sausage', function(e){
self.hasScrolled = true;
@@ -149,7 +149,7 @@
return;
},
- // ## ._getCurrent()
+ // ## `._getCurrent()`
//
//
_getCurrent: function () {
@@ -179,7 +179,7 @@
return i;
},
- // ## ._delegates()
+ // ## `._delegates()`
//
//
_delegates: function () {
@@ -211,9 +211,7 @@
val = $sausage.index(),
o = self.$inner.find(self.options.page).eq(val).offset().top;
- self.$outer
- .scrollTop(o)
- ;
+ self._scrollTo(o);
// Trigger the `onClick` event.
//
@@ -248,7 +246,42 @@
return;
},
- // ## ._update()
+ _scrollTo: function (o) {
+
+ var self = this,
+ $outer = self.$outer,
+ rate = 2/1, // px/ms
+ distance = self.offsets[self.current] - o,
+ duration = Math.abs(distance/rate);
+ // Travel at 2 px per 1 ms but never longer than 1 s.
+ duration = (duration < 1000) ? duration : 1000;
+
+ //// TODO: Animate scrollTop fails on `window`, research this
+ if (self.$outer.get(0) === window)
+ {
+ $outer = $('html, document');
+ }
+
+ $outer
+ .stop(true)
+ .animate({
+ scrollTop: o
+ }, duration)
+ ;
+
+ return;
+ },
+
+ _handleClick: function () {
+
+ var self = this
+
+
+
+ return;
+ },
+
+ // ## `._update()`
//
//
_update: function () {
@@ -276,7 +309,7 @@
return;
},
- // ### ._getHandleHeight()
+ // ### `._getHandleHeight()`
//
//
_getHandleHeight: function ($outer, $inner) {
@@ -380,6 +413,10 @@
var self = this;
+ self.$outer
+ .unbind('.sausage')
+ ;
+
self.$sausages
.remove()
;
View
1  lib/sausage.css
@@ -16,6 +16,7 @@
-webkit-border-top-right-radius: 8px;
-moz-box-shadow: inset 0px 1px 2px 4px rgba(0, 0, 0, 0.025);
-webkit-box-shadow: inset 0px 1px 2px 4px rgba(0, 0, 0, 0.025);
+ cursor: pointer;
}
.sausage-hover,
.sausage-current {
Please sign in to comment.
Something went wrong with that request. Please try again.