|
65 | 65 | }
|
66 | 66 |
|
67 | 67 | /**
|
68 |
| - * The PageAnimation constructor |
| 68 | + * The Pangea constructor |
69 | 69 | *
|
70 | 70 | * @param {Object} options - Configuration options
|
71 | 71 | * @param {bool} options.shouldScroll - whether or we should scroll the page
|
|
93 | 93 | * @param {function} options.onTransitionEnd - a function to run once the
|
94 | 94 | * animation is complete.
|
95 | 95 | */
|
96 |
| - function PageAnimation(options) { |
| 96 | + function Pangea(options) { |
97 | 97 |
|
98 | 98 | var opts = options || {};
|
99 | 99 |
|
|
142 | 142 | * @param {Object} options - Configuration options
|
143 | 143 | * @param {bool} options.shouldScroll - whether or not we should scroll the
|
144 | 144 | * page as part of this animation.
|
145 |
| - * defualt: the value of options.shouldScroll passed into PageAnimation() |
| 145 | + * defualt: the value of options.shouldScroll passed into Pangea() |
146 | 146 | * @param {bool} options.scrollTiming - the scroll timing for this animation
|
147 | 147 | * options:
|
148 | 148 | * 'before': scroll the page before starting animations
|
149 | 149 | * 'during': scroll the page and start the animations at the same time
|
150 | 150 | * 'after': scroll once the animations are complete
|
151 |
| - * default: the value of options.scrollTiming passed into PageAnimation() |
| 151 | + * default: the value of options.scrollTiming passed into Pangea() |
152 | 152 | * @param {Number} options.scrollDuration - the scroll speed in ms.
|
153 |
| - * default: the value of options.scrollDuration passed into PageAnimation() |
| 153 | + * default: the value of options.scrollDuration passed into Pangea() |
154 | 154 | *
|
155 |
| - * @returns the new PageAnimation instance. |
| 155 | + * @returns the new Pangea instance. |
156 | 156 | */
|
157 |
| - PageAnimation.prototype.register = function(urlRegex, finalElementId, bodyClass, options) { |
| 157 | + Pangea.prototype.register = function(urlRegex, finalElementId, bodyClass, options) { |
158 | 158 | // Create the animation
|
159 | 159 | var opts = options || {};
|
160 | 160 | var animation = {
|
|
183 | 183 | * Deregisters the animation for the passed urlRegex
|
184 | 184 | *
|
185 | 185 | * @param {string} urlRegex - the same pattern that was passed into
|
186 |
| - * PageAnimation.register() |
| 186 | + * Pangea.register() |
187 | 187 | *
|
188 |
| - * @returns the PageAnimation instance. |
| 188 | + * @returns the Pangea instance. |
189 | 189 | */
|
190 |
| - PageAnimation.prototype.deregister = function(urlRegex) { |
| 190 | + Pangea.prototype.deregister = function(urlRegex) { |
191 | 191 | if (!this.animations[urlRegex]) {
|
192 | 192 | console.error('No animation registered with regex ' + urlRegex);
|
193 | 193 | }
|
|
199 | 199 | };
|
200 | 200 |
|
201 | 201 | /**
|
202 |
| - * Enable the PageAnimation library by beginning to listen to click events, |
| 202 | + * Enable the Pangea library by beginning to listen to click events, |
203 | 203 | * running animations appropriately.
|
204 | 204 | */
|
205 |
| - PageAnimation.prototype.enable = function() { |
| 205 | + Pangea.prototype.enable = function() { |
206 | 206 | for (var i = 0; i < this.links.length; i++) {
|
207 | 207 | this.links[i].addEventListener('click', this.boundOnClick);
|
208 | 208 | }
|
209 | 209 | };
|
210 | 210 |
|
211 | 211 | /**
|
212 |
| - * Disable the PageAnimation library by removing event listeners set in |
213 |
| - * `PageAnimation.enable()`. |
| 212 | + * Disable the Pangea library by removing event listeners set in |
| 213 | + * `Pangea.enable()`. |
214 | 214 | */
|
215 |
| - PageAnimation.prototype.disable = function() { |
| 215 | + Pangea.prototype.disable = function() { |
216 | 216 | for (var i = 0; i < this.links.length; i++) {
|
217 | 217 | this.links[i].removeEventListener('click', this.boundOnClick);
|
218 | 218 | }
|
|
225 | 225 | * @param {int} scrollDuration - how long the scroll should take, in ms
|
226 | 226 | * @param {function} cb - callback to call when the scroll is complete
|
227 | 227 | */
|
228 |
| - PageAnimation.scrollTo = function(offset, scrollDuration, cb) { |
| 228 | + Pangea.scrollTo = function(offset, scrollDuration, cb) { |
229 | 229 | cb = cb || function() {};
|
230 | 230 | var startT = Date.now();
|
231 | 231 | var startY = window.scrollY;
|
|
260 | 260 | *
|
261 | 261 | * @param {Object} e - the transition end event object.
|
262 | 262 | */
|
263 |
| - PageAnimation.prototype._onTransitionEnd = function(e) { |
| 263 | + Pangea.prototype._onTransitionEnd = function(e) { |
264 | 264 | if (!this.currentAnimation) {
|
265 | 265 | return;
|
266 | 266 | }
|
|
287 | 287 | }.bind(this);
|
288 | 288 |
|
289 | 289 | if (animation.shouldScroll && animation.scrollTiming === 'after') {
|
290 |
| - PageAnimation.scrollTo(this.cb.computeScrollOffset(animation), animation.scrollDuration, followLink); |
| 290 | + Pangea.scrollTo(this.cb.computeScrollOffset(animation), animation.scrollDuration, followLink); |
291 | 291 | } else {
|
292 | 292 | followLink();
|
293 | 293 | }
|
|
308 | 308 | * as part of this animation
|
309 | 309 | * @param {string} animation.scrollTiming - when to scroll the page
|
310 | 310 | */
|
311 |
| - PageAnimation.prototype._animate = function(animation) { |
| 311 | + Pangea.prototype._animate = function(animation) { |
312 | 312 | this.cb.beforeAnimationStart(animation);
|
313 | 313 | animation.finalElement.addEventListener(this.transitionEndEvent, this.boundOnTransitionEnd);
|
314 | 314 | this.currentAnimation = animation;
|
|
318 | 318 | }.bind(this);
|
319 | 319 |
|
320 | 320 | if (animation.shouldScroll && animation.scrollTiming === 'before') {
|
321 |
| - PageAnimation.scrollTo(this.cb.computeScrollOffset(animation), animation.scrollDuration, startAnimation); |
| 321 | + Pangea.scrollTo(this.cb.computeScrollOffset(animation), animation.scrollDuration, startAnimation); |
322 | 322 | } else if (animation.shouldScroll && animation.scrollTiming === 'during') {
|
323 | 323 | setTimeout(startAnimation, 0);
|
324 |
| - PageAnimation.scrollTo(this.cb.computeScrollOffset(animation), animation.scrollDuration); |
| 324 | + Pangea.scrollTo(this.cb.computeScrollOffset(animation), animation.scrollDuration); |
325 | 325 | } else {
|
326 | 326 | startAnimation();
|
327 | 327 | }
|
|
335 | 335 | *
|
336 | 336 | * @param {Object} e - the click event object.
|
337 | 337 | */
|
338 |
| - PageAnimation.prototype._onClick = function(e) { |
| 338 | + Pangea.prototype._onClick = function(e) { |
339 | 339 | var anchor = _getTargetAnchor(e);
|
340 | 340 | var path = _getAnchorPath(anchor);
|
341 | 341 |
|
|
358 | 358 | };
|
359 | 359 |
|
360 | 360 | if (typeof define === 'function' && define.amd) {
|
361 |
| - define(PageAnimation); |
| 361 | + define(Pangea); |
362 | 362 | } else if (typeof module !== 'undefined' && module.exports) {
|
363 |
| - module.exports = PageAnimation; |
| 363 | + module.exports = Pangea; |
364 | 364 | } else {
|
365 |
| - global.PageAnimation = PageAnimation; |
| 365 | + global.Pangea = Pangea; |
366 | 366 | }
|
367 | 367 |
|
368 | 368 | }(this));
|
0 commit comments