| Index: elements/viewer-page-indicator/viewer-page-indicator.js
|
| diff --git a/elements/viewer-page-indicator/viewer-page-indicator.js b/elements/viewer-page-indicator/viewer-page-indicator.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e22b5a6f91c496e2e3b2ee36080d10bff8527589
|
| --- /dev/null
|
| +++ b/elements/viewer-page-indicator/viewer-page-indicator.js
|
| @@ -0,0 +1,31 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +Polymer('viewer-page-indicator', {
|
| + text: '1',
|
| + timerId: undefined,
|
| + ready: function() {
|
| + var callback = this.fadeIn.bind(this, 2000);
|
| + window.addEventListener('scroll', function() {
|
| + requestAnimationFrame(callback);
|
| + });
|
| + },
|
| + initialFadeIn: function() {
|
| + this.fadeIn(6000);
|
| + },
|
| + fadeIn: function(displayTime) {
|
| + var percent = window.scrollY /
|
| + (document.body.scrollHeight -
|
| + document.documentElement.clientHeight);
|
| + this.style.top = percent *
|
| + (document.documentElement.clientHeight - this.offsetHeight) + 'px';
|
| + this.style.opacity = 1;
|
| + clearTimeout(this.timerId);
|
| +
|
| + this.timerId = setTimeout(function() {
|
| + this.style.opacity = 0;
|
| + this.timerId = undefined;
|
| + }.bind(this), displayTime);
|
| + }
|
| +});
|
|
|