Show More
@@ -6,6 +6,7 define([], function(){ | |||||
6 | var ScrollManager = function (notebook) { |
|
6 | var ScrollManager = function (notebook) { | |
7 | // Public constructor. |
|
7 | // Public constructor. | |
8 | this.notebook = notebook; |
|
8 | this.notebook = notebook; | |
|
9 | this.animation_speed = 250; //ms | |||
9 | }; |
|
10 | }; | |
10 |
|
11 | |||
11 | ScrollManager.prototype.scroll = function (delta) { |
|
12 | ScrollManager.prototype.scroll = function (delta) { | |
@@ -60,14 +61,22 define([], function(){ | |||||
60 | // Cancel browser keyboard scroll. |
|
61 | // Cancel browser keyboard scroll. | |
61 | return false; |
|
62 | return false; | |
62 |
|
63 | |||
63 | // No slides exist, default browser scroll |
|
64 | // No slides exist, scroll up or down one page height. Instead of using | |
|
65 | // the browser's built in method to do this, animate it using jQuery. | |||
64 | } else { |
|
66 | } else { | |
65 | return true; |
|
67 | this.scroll_some(delta); | |
|
68 | return false; | |||
66 | } |
|
69 | } | |
67 | }; |
|
70 | }; | |
68 |
|
71 | |||
69 | ScrollManager.prototype.scroll_to = function(destination) { |
|
72 | ScrollManager.prototype.scroll_to = function(destination) { | |
70 | $('html, body').animate({'scrollTop': element.offset().top}, 'slow', 'swing'); |
|
73 | // Scroll to an element in the notebook. | |
|
74 | $('#notebook').animate({'scrollTop': $(destination).offset().top + $('#notebook').scrollTop() - $('#notebook').offset().top}, this.animation_speed); | |||
|
75 | }; | |||
|
76 | ||||
|
77 | ScrollManager.prototype.scroll_some = function(pages) { | |||
|
78 | // Scroll up or down a given number of pages. | |||
|
79 | $('#notebook').animate({'scrollTop': $('#notebook').scrollTop() + pages * $('#notebook').height()}, this.animation_speed); | |||
71 | }; |
|
80 | }; | |
72 |
|
81 | |||
73 | // For convinience, add the ScrollManager class to the global namespace |
|
82 | // For convinience, add the ScrollManager class to the global namespace |
General Comments 0
You need to be logged in to leave comments.
Login now