| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 // Copyright 2015 The Chromium Authors. All rights reserved. | 2 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 --> | 5 --> |
| 6 <import src="animation/controller.sky" as="AnimationController" /> | 6 <import src="animation/controller.sky" as="AnimationController" /> |
| 7 <import src="animation/curves.sky" as="Curves" /> | 7 <import src="animation/curves.sky" as="Curves" /> |
| 8 <import src="sky-element/sky-element.sky" as="SkyElement" /> | 8 <import src="sky-element/sky-element.sky" as="SkyElement" /> |
| 9 <import src="sky-scrollable.sky" /> | 9 <import src="sky-scrollable.sky" /> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 </div> | 41 </div> |
| 42 </template> | 42 </template> |
| 43 <script> | 43 <script> |
| 44 const kWidth = 256; | 44 const kWidth = 256; |
| 45 const kMinAnimationDurationMS = 120; | 45 const kMinAnimationDurationMS = 120; |
| 46 const kMaxAnimationDurationMS = 500; | 46 const kMaxAnimationDurationMS = 500; |
| 47 const kAnimationCurve = Curves.easeInOut; | 47 const kAnimationCurve = Curves.easeInOut; |
| 48 | 48 |
| 49 module.exports = class extends SkyElement { | 49 module.exports = class extends SkyElement { |
| 50 created() { | 50 created() { |
| 51 this.previousX_ = 0; | |
| 52 this.position_ = 0; | 51 this.position_ = 0; |
| 53 this.mask_ = null; | 52 this.mask_ = null; |
| 54 this.content_ = null; | 53 this.content_ = null; |
| 55 this.animation_ = new AnimationController(this); | 54 this.animation_ = new AnimationController(this); |
| 56 } | 55 } |
| 57 | 56 |
| 58 shadowRootReady() { | 57 shadowRootReady() { |
| 59 this.mask_ = this.shadowRoot.getElementById('mask'); | 58 this.mask_ = this.shadowRoot.getElementById('mask'); |
| 60 this.content_ = this.shadowRoot.getElementById('content'); | 59 this.content_ = this.shadowRoot.getElementById('content'); |
| 61 this.position = -kWidth; | 60 this.position = -kWidth; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 updateAnimation(position) { | 117 updateAnimation(position) { |
| 119 this.position = position; | 118 this.position = position; |
| 120 } | 119 } |
| 121 | 120 |
| 122 handleMaskClick() { | 121 handleMaskClick() { |
| 123 this.close(); | 122 this.close(); |
| 124 } | 123 } |
| 125 | 124 |
| 126 handlePointerDown(event) { | 125 handlePointerDown(event) { |
| 127 this.animation_.stop(); | 126 this.animation_.stop(); |
| 128 this.previousX_ = event.x; | |
| 129 } | 127 } |
| 130 | 128 |
| 131 handlePointerMove(event) { | 129 handlePointerMove(event) { |
| 132 // TODO(abarth): Implement event.dx; | 130 this.position += event.dx; |
| 133 var deltaX = event.x - this.previousX_; | |
| 134 this.previousX_ = event.x; | |
| 135 this.position += deltaX; | |
| 136 } | 131 } |
| 137 | 132 |
| 138 handlePointerUp(event) { | 133 handlePointerUp(event) { |
| 139 if (!this.animation_.isAnimating) | 134 if (!this.animation_.isAnimating) |
| 140 this.settle_(); | 135 this.settle_(); |
| 141 } | 136 } |
| 142 | 137 |
| 143 handlePointerCancel(event) { | 138 handlePointerCancel(event) { |
| 144 if (!this.animation_.isAnimating) | 139 if (!this.animation_.isAnimating) |
| 145 this.settle_(); | 140 this.settle_(); |
| 146 } | 141 } |
| 147 }.register(); | 142 }.register(); |
| 148 </script> | 143 </script> |
| 149 </sky-element> | 144 </sky-element> |
| OLD | NEW |