OLD | NEW |
1 // Copyright (c) 2012 The Polymer Authors. All rights reserved. | 1 // Copyright (c) 2012 The Polymer Authors. All rights reserved. |
2 // | 2 // |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following disclaimer | 10 // copyright notice, this list of conditions and the following disclaimer |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 } | 441 } |
442 }, | 442 }, |
443 latchableChanged: function() { | 443 latchableChanged: function() { |
444 if (this.latchable) | 444 if (this.latchable) |
445 this.classList.add('latchable'); | 445 this.classList.add('latchable'); |
446 else | 446 else |
447 this.classList.remove('latchable'); | 447 this.classList.remove('latchable'); |
448 }, | 448 }, |
449 }); | 449 }); |
450 })(); | 450 })(); |
| 451 ; |
| 452 |
| 453 Polymer('viewer-page-indicator', { |
| 454 text: '1', |
| 455 timerId: undefined, |
| 456 ready: function() { |
| 457 var scrollCallback = function() { |
| 458 var percent = window.scrollY / |
| 459 (document.body.scrollHeight - |
| 460 document.documentElement.clientHeight); |
| 461 this.style.top = percent * |
| 462 (document.documentElement.clientHeight - this.offsetHeight) + 'px'; |
| 463 this.style.opacity = 1; |
| 464 clearTimeout(this.timerId); |
| 465 |
| 466 this.timerId = setTimeout(function() { |
| 467 this.style.opacity = 0; |
| 468 this.timerId = undefined; |
| 469 }.bind(this), 2000); |
| 470 }.bind(this); |
| 471 window.addEventListener('scroll', function() { |
| 472 requestAnimationFrame(scrollCallback); |
| 473 }); |
| 474 |
| 475 scrollCallback(); |
| 476 }, |
| 477 }); |
| 478 ; |
| 479 |
| 480 Polymer('viewer-progress-bar', { |
| 481 progress: 0, |
| 482 text: 'Loading', |
| 483 numSegments: 8, |
| 484 segments: [], |
| 485 ready: function() { |
| 486 this.numSegmentsChanged(); |
| 487 }, |
| 488 progressChanged: function() { |
| 489 var numVisible = this.progress * this.segments.length / 100.0; |
| 490 for (var i = 0; i < this.segments.length; i++) { |
| 491 this.segments[i].style.visibility = |
| 492 i < numVisible ? 'visible' : 'hidden'; |
| 493 } |
| 494 |
| 495 if (this.progress >= 100 || this.progress < 0) |
| 496 this.style.opacity = 0; |
| 497 }, |
| 498 numSegmentsChanged: function() { |
| 499 // Clear the existing segments. |
| 500 this.segments = []; |
| 501 var segmentsElement = this.$.segments; |
| 502 segmentsElement.innerHTML = ''; |
| 503 |
| 504 // Create the new segments. |
| 505 var segment = document.createElement('li'); |
| 506 segment.classList.add('segment'); |
| 507 var angle = 360 / this.numSegments; |
| 508 for (var i = 0; i < this.numSegments; ++i) { |
| 509 var segmentCopy = segment.cloneNode(true); |
| 510 segmentCopy.style.webkitTransform = |
| 511 'rotate(' + (i * angle) + 'deg) skewY(' + |
| 512 -1 * (90 - angle) + 'deg)'; |
| 513 segmentsElement.appendChild(segmentCopy); |
| 514 this.segments.push(segmentCopy); |
| 515 } |
| 516 this.progressChanged(); |
| 517 } |
| 518 }); |
OLD | NEW |