| OLD | NEW |
| 1 | 1 |
| 2 | 2 |
| 3 (function() { | 3 (function() { |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 // this would be the only `paper-drawer-panel` in |
| 8 // the whole app that can be in `dragging` state |
| 9 var sharedPanel = null; |
| 10 |
| 7 function classNames(obj) { | 11 function classNames(obj) { |
| 8 var classNames = []; | 12 var classes = []; |
| 9 for (var key in obj) { | 13 for (var key in obj) { |
| 10 if (obj.hasOwnProperty(key) && obj[key]) { | 14 if (obj.hasOwnProperty(key) && obj[key]) { |
| 11 classNames.push(key); | 15 classes.push(key); |
| 12 } | 16 } |
| 13 } | 17 } |
| 14 | 18 |
| 15 return classNames.join(' '); | 19 return classes.join(' '); |
| 16 } | 20 } |
| 17 | 21 |
| 18 Polymer({ | 22 Polymer({ |
| 19 | 23 |
| 20 is: 'paper-drawer-panel', | 24 is: 'paper-drawer-panel', |
| 21 | 25 |
| 22 /** | 26 /** |
| 23 * Fired when the narrow layout changes. | 27 * Fired when the narrow layout changes. |
| 24 * | 28 * |
| 25 * @event paper-responsive-change {{narrow: boolean}} detail - | 29 * @event paper-responsive-change {{narrow: boolean}} detail - |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 * @event paper-select {{isSelected: boolean, item: Object}} detail - | 40 * @event paper-select {{isSelected: boolean, item: Object}} detail - |
| 37 * isSelected: True for selection and false for deselection. | 41 * isSelected: True for selection and false for deselection. |
| 38 * item: The panel that the event refers to. | 42 * item: The panel that the event refers to. |
| 39 */ | 43 */ |
| 40 | 44 |
| 41 properties: { | 45 properties: { |
| 42 | 46 |
| 43 /** | 47 /** |
| 44 * The panel to be selected when `paper-drawer-panel` changes to narrow | 48 * The panel to be selected when `paper-drawer-panel` changes to narrow |
| 45 * layout. | 49 * layout. |
| 46 * | |
| 47 * @attribute defaultSelected | |
| 48 * @type string | |
| 49 * @default 'main' | |
| 50 */ | 50 */ |
| 51 defaultSelected: { | 51 defaultSelected: { |
| 52 type: String, | 52 type: String, |
| 53 value: 'main' | 53 value: 'main' |
| 54 }, | 54 }, |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * If true, swipe from the edge is disable. | 57 * If true, swipe from the edge is disable. |
| 58 * | |
| 59 * @attribute disableEdgeSwipe | |
| 60 * @type boolean | |
| 61 * @default false | |
| 62 */ | 58 */ |
| 63 disableEdgeSwipe: Boolean, | 59 disableEdgeSwipe: { |
| 60 type: Boolean, |
| 61 value: false |
| 62 }, |
| 64 | 63 |
| 65 /** | 64 /** |
| 66 * If true, swipe to open/close the drawer is disabled. | 65 * If true, swipe to open/close the drawer is disabled. |
| 67 * | |
| 68 * @attribute disableSwipe | |
| 69 * @type boolean | |
| 70 * @default false | |
| 71 */ | 66 */ |
| 72 disableSwipe: Boolean, | 67 disableSwipe: { |
| 68 type: Boolean, |
| 69 value: false |
| 70 }, |
| 73 | 71 |
| 74 // Whether the user is dragging the drawer interactively. | 72 /** |
| 73 * Whether the user is dragging the drawer interactively. |
| 74 */ |
| 75 dragging: { | 75 dragging: { |
| 76 type: Boolean, | 76 type: Boolean, |
| 77 value: false | 77 value: false |
| 78 }, | 78 }, |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * Width of the drawer panel. | 81 * Width of the drawer panel. |
| 82 * | |
| 83 * @attribute drawerWidth | |
| 84 * @type string | |
| 85 * @default '256px' | |
| 86 */ | 82 */ |
| 87 drawerWidth: { | 83 drawerWidth: { |
| 88 type: String, | 84 type: String, |
| 89 value: '256px' | 85 value: '256px' |
| 90 }, | 86 }, |
| 91 | 87 |
| 92 // How many pixels on the side of the screen are sensitive to edge | 88 /** |
| 93 // swipes and peek. | 89 * How many pixels on the side of the screen are sensitive to edge |
| 90 * swipes and peek. |
| 91 */ |
| 94 edgeSwipeSensitivity: { | 92 edgeSwipeSensitivity: { |
| 95 type: Number, | 93 type: Number, |
| 96 value: 30 | 94 value: 30 |
| 97 }, | 95 }, |
| 98 | 96 |
| 99 /** | 97 /** |
| 100 * If true, ignore `responsiveWidth` setting and force the narrow layout
. | 98 * If true, ignore `responsiveWidth` setting and force the narrow layout
. |
| 101 * | |
| 102 * @attribute forceNarrow | |
| 103 * @type boolean | |
| 104 * @default false | |
| 105 */ | 99 */ |
| 106 forceNarrow: { | 100 forceNarrow: { |
| 107 observer: 'forceNarrowChanged', | |
| 108 type: Boolean, | 101 type: Boolean, |
| 109 value: false | 102 value: false |
| 110 }, | 103 }, |
| 111 | 104 |
| 112 // Whether the browser has support for the transform CSS property. | 105 /** |
| 106 * Whether the browser has support for the transform CSS property. |
| 107 */ |
| 113 hasTransform: { | 108 hasTransform: { |
| 114 type: Boolean, | 109 type: Boolean, |
| 115 value: function() { | 110 value: function() { |
| 116 return 'transform' in this.style; | 111 return 'transform' in this.style; |
| 117 } | 112 } |
| 118 }, | 113 }, |
| 119 | 114 |
| 120 // Whether the browser has support for the will-change CSS property. | 115 /** |
| 116 * Whether the browser has support for the will-change CSS property. |
| 117 */ |
| 121 hasWillChange: { | 118 hasWillChange: { |
| 122 type: Boolean, | 119 type: Boolean, |
| 123 value: function() { | 120 value: function() { |
| 124 return 'willChange' in this.style; | 121 return 'willChange' in this.style; |
| 125 } | 122 } |
| 126 }, | 123 }, |
| 127 | 124 |
| 128 /** | 125 /** |
| 129 * Returns true if the panel is in narrow layout. This is useful if you | 126 * Returns true if the panel is in narrow layout. This is useful if you |
| 130 * need to show/hide elements based on the layout. | 127 * need to show/hide elements based on the layout. |
| 131 * | |
| 132 * @attribute narrow | |
| 133 * @type boolean | |
| 134 * @default false | |
| 135 */ | 128 */ |
| 136 narrow: { | 129 narrow: { |
| 137 reflectToAttribute: true, | 130 reflectToAttribute: true, |
| 138 type: Boolean, | 131 type: Boolean, |
| 139 value: false, | 132 value: false, |
| 140 notify: true | 133 notify: true |
| 141 }, | 134 }, |
| 142 | 135 |
| 143 // Whether the drawer is peeking out from the edge. | 136 /** |
| 137 * Whether the drawer is peeking out from the edge. |
| 138 */ |
| 144 peeking: { | 139 peeking: { |
| 145 type: Boolean, | 140 type: Boolean, |
| 146 value: false | 141 value: false |
| 147 }, | 142 }, |
| 148 | 143 |
| 149 /** | 144 /** |
| 150 * Max-width when the panel changes to narrow layout. | 145 * Max-width when the panel changes to narrow layout. |
| 151 * | |
| 152 * @attribute responsiveWidth | |
| 153 * @type string | |
| 154 * @default '640px' | |
| 155 */ | 146 */ |
| 156 responsiveWidth: { | 147 responsiveWidth: { |
| 157 type: String, | 148 type: String, |
| 158 value: '640px' | 149 value: '640px' |
| 159 }, | 150 }, |
| 160 | 151 |
| 161 /** | 152 /** |
| 162 * If true, position the drawer to the right. | 153 * If true, position the drawer to the right. |
| 163 * | |
| 164 * @attribute rightDrawer | |
| 165 * @type boolean | |
| 166 * @default false | |
| 167 */ | 154 */ |
| 168 rightDrawer: { | 155 rightDrawer: { |
| 169 type: Boolean, | 156 type: Boolean, |
| 170 value: false | 157 value: false |
| 171 }, | 158 }, |
| 172 | 159 |
| 173 /** | 160 /** |
| 174 * The panel that is being selected. `drawer` for the drawer panel and | 161 * The panel that is being selected. `drawer` for the drawer panel and |
| 175 * `main` for the main panel. | 162 * `main` for the main panel. |
| 176 * | |
| 177 * @attribute selected | |
| 178 * @type string | |
| 179 * @default null | |
| 180 */ | 163 */ |
| 181 selected: { | 164 selected: { |
| 182 reflectToAttribute: true, | 165 reflectToAttribute: true, |
| 183 type: String, | 166 type: String, |
| 184 value: null | 167 value: null |
| 185 }, | 168 }, |
| 186 | 169 |
| 187 /** | 170 /** |
| 188 * The attribute on elements that should toggle the drawer on tap, also
elements will | 171 * The attribute on elements that should toggle the drawer on tap, also
elements will |
| 189 * automatically be hidden in wide layout. | 172 * automatically be hidden in wide layout. |
| 190 */ | 173 */ |
| 191 drawerToggleAttribute: { | 174 drawerToggleAttribute: { |
| 192 type: String, | 175 type: String, |
| 193 value: 'paper-drawer-toggle' | 176 value: 'paper-drawer-toggle' |
| 194 }, | 177 }, |
| 195 | 178 |
| 196 /** | 179 /** |
| 197 * Whether the transition is enabled. | 180 * Whether the transition is enabled. |
| 198 */ | 181 */ |
| 199 transition: { | 182 transition: { |
| 200 type: Boolean, | 183 type: Boolean, |
| 201 value: false | 184 value: false |
| 202 }, | 185 }, |
| 203 | 186 |
| 204 /** | |
| 205 * Starting X coordinate of a tracking gesture. It is non-null only betw
een trackStart and | |
| 206 * trackEnd events. | |
| 207 * @type {?number} | |
| 208 */ | |
| 209 _startX: { | |
| 210 type: Number, | |
| 211 value: null | |
| 212 } | |
| 213 | |
| 214 }, | 187 }, |
| 215 | 188 |
| 216 listeners: { | 189 listeners: { |
| 217 tap: '_onTap', | 190 tap: '_onTap', |
| 218 track: '_onTrack' | 191 track: '_onTrack', |
| 192 down: '_downHandler', |
| 193 up: '_upHandler' |
| 194 }, |
| 219 | 195 |
| 220 // TODO: Implement tap handlers when taps are supported. | 196 observers: [ |
| 221 // | 197 '_forceNarrowChanged(forceNarrow, defaultSelected)' |
| 222 // down: 'downHandler', | 198 ], |
| 223 // up: 'upHandler' | 199 |
| 200 /** |
| 201 * Toggles the panel open and closed. |
| 202 * |
| 203 * @method togglePanel |
| 204 */ |
| 205 togglePanel: function() { |
| 206 if (this._isMainSelected()) { |
| 207 this.openDrawer(); |
| 208 } else { |
| 209 this.closeDrawer(); |
| 210 } |
| 211 }, |
| 212 |
| 213 /** |
| 214 * Opens the drawer. |
| 215 * |
| 216 * @method openDrawer |
| 217 */ |
| 218 openDrawer: function() { |
| 219 this.selected = 'drawer'; |
| 220 }, |
| 221 |
| 222 /** |
| 223 * Closes the drawer. |
| 224 * |
| 225 * @method closeDrawer |
| 226 */ |
| 227 closeDrawer: function() { |
| 228 this.selected = 'main'; |
| 229 }, |
| 230 |
| 231 ready: function() { |
| 232 // Avoid transition at the beginning e.g. page loads and enable |
| 233 // transitions only after the element is rendered and ready. |
| 234 this.transition = true; |
| 224 }, | 235 }, |
| 225 | 236 |
| 226 _computeIronSelectorClass: function(narrow, transition, dragging, rightDra
wer) { | 237 _computeIronSelectorClass: function(narrow, transition, dragging, rightDra
wer) { |
| 227 return classNames({ | 238 return classNames({ |
| 228 dragging: dragging, | 239 dragging: dragging, |
| 229 'narrow-layout': narrow, | 240 'narrow-layout': narrow, |
| 230 'right-drawer': rightDrawer, | 241 'right-drawer': rightDrawer, |
| 242 'left-drawer': !rightDrawer, |
| 231 transition: transition | 243 transition: transition |
| 232 }); | 244 }); |
| 233 }, | 245 }, |
| 234 | 246 |
| 235 _computeDrawerStyle: function(drawerWidth) { | 247 _computeDrawerStyle: function(drawerWidth) { |
| 236 return 'width:' + drawerWidth + ';'; | 248 return 'width:' + drawerWidth + ';'; |
| 237 }, | 249 }, |
| 238 | 250 |
| 239 _computeMainStyle: function(narrow, rightDrawer, drawerWidth) { | 251 _computeMainStyle: function(narrow, rightDrawer, drawerWidth) { |
| 240 var style = ''; | 252 var style = ''; |
| 241 | 253 |
| 242 style += 'left:' + ((narrow || rightDrawer) ? '0' : drawerWidth) + ';' | 254 style += 'left:' + ((narrow || rightDrawer) ? '0' : drawerWidth) + ';'; |
| 243 | 255 |
| 244 if (rightDrawer) { | 256 if (rightDrawer) { |
| 245 style += 'right:' + (narrow ? '' : drawerWidth) + ';'; | 257 style += 'right:' + (narrow ? '' : drawerWidth) + ';'; |
| 246 } else { | 258 } else { |
| 247 style += 'right:;' | 259 style += 'right:;'; |
| 248 } | 260 } |
| 249 | 261 |
| 250 return style; | 262 return style; |
| 251 }, | 263 }, |
| 252 | 264 |
| 253 _computeMediaQuery: function(forceNarrow, responsiveWidth) { | 265 _computeMediaQuery: function(forceNarrow, responsiveWidth) { |
| 254 return forceNarrow ? '' : '(max-width: ' + responsiveWidth + ')'; | 266 return forceNarrow ? '' : '(max-width: ' + responsiveWidth + ')'; |
| 255 }, | 267 }, |
| 256 | 268 |
| 257 _computeSwipeOverlayHidden: function(narrow, disableEdgeSwipe) { | 269 _computeSwipeOverlayHidden: function(narrow, disableEdgeSwipe) { |
| 258 return !narrow || disableEdgeSwipe; | 270 return !narrow || disableEdgeSwipe; |
| 259 }, | 271 }, |
| 260 | 272 |
| 261 _onTrack: function(event) { | 273 _onTrack: function(e) { |
| 262 switch (event.detail.state) { | 274 if (sharedPanel && this !== sharedPanel) { |
| 275 return; |
| 276 } |
| 277 switch (e.detail.state) { |
| 278 case 'start': |
| 279 this._trackStart(e); |
| 280 break; |
| 281 case 'track': |
| 282 this._trackX(e); |
| 283 break; |
| 263 case 'end': | 284 case 'end': |
| 264 this.trackEnd(event); | 285 this._trackEnd(e); |
| 265 break; | |
| 266 case 'move': | |
| 267 this.trackX(event); | |
| 268 break; | |
| 269 case 'start': | |
| 270 this.trackStart(event); | |
| 271 break; | 286 break; |
| 272 } | 287 } |
| 273 }, | |
| 274 | 288 |
| 275 ready: function() { | |
| 276 // Avoid transition at the beginning e.g. page loads and enable | |
| 277 // transitions only after the element is rendered and ready. | |
| 278 this.transition = true; | |
| 279 }, | |
| 280 | |
| 281 /** | |
| 282 * Toggles the panel open and closed. | |
| 283 * | |
| 284 * @method togglePanel | |
| 285 */ | |
| 286 togglePanel: function() { | |
| 287 if (this.isMainSelected()) { | |
| 288 this.openDrawer(); | |
| 289 } else { | |
| 290 this.closeDrawer(); | |
| 291 } | |
| 292 }, | |
| 293 | |
| 294 /** | |
| 295 * Opens the drawer. | |
| 296 * | |
| 297 * @method openDrawer | |
| 298 */ | |
| 299 openDrawer: function() { | |
| 300 this.selected = 'drawer'; | |
| 301 }, | |
| 302 | |
| 303 /** | |
| 304 * Closes the drawer. | |
| 305 * | |
| 306 * @method closeDrawer | |
| 307 */ | |
| 308 closeDrawer: function() { | |
| 309 this.selected = 'main'; | |
| 310 }, | 289 }, |
| 311 | 290 |
| 312 _responsiveChange: function(narrow) { | 291 _responsiveChange: function(narrow) { |
| 313 this.narrow = narrow; | 292 this.narrow = narrow; |
| 314 | 293 |
| 315 if (this.narrow) { | 294 if (this.narrow) { |
| 316 this.selected = this.defaultSelected; | 295 this.selected = this.defaultSelected; |
| 317 } | 296 } |
| 318 | 297 |
| 319 this.setAttribute('touch-action', this.swipeAllowed() ? 'pan-y' : ''); | 298 this.setScrollDirection(this._swipeAllowed() ? 'y' : 'all'); |
| 320 this.fire('paper-responsive-change', {narrow: this.narrow}); | 299 this.fire('paper-responsive-change', {narrow: this.narrow}); |
| 321 }, | 300 }, |
| 322 | 301 |
| 323 onQueryMatchesChanged: function(e) { | 302 _onQueryMatchesChanged: function(e) { |
| 324 this._responsiveChange(e.detail.value); | 303 this._responsiveChange(e.detail.value); |
| 325 }, | 304 }, |
| 326 | 305 |
| 327 forceNarrowChanged: function() { | 306 _forceNarrowChanged: function() { |
| 328 this._responsiveChange(this.forceNarrow); | 307 // set the narrow mode only if we reached the `responsiveWidth` |
| 308 this._responsiveChange(this.forceNarrow || this.$.mq.queryMatches); |
| 329 }, | 309 }, |
| 330 | 310 |
| 331 swipeAllowed: function() { | 311 _swipeAllowed: function() { |
| 332 return this.narrow && !this.disableSwipe; | 312 return this.narrow && !this.disableSwipe; |
| 333 }, | 313 }, |
| 334 | 314 |
| 335 isMainSelected: function() { | 315 _isMainSelected: function() { |
| 336 return this.selected === 'main'; | 316 return this.selected === 'main'; |
| 337 }, | 317 }, |
| 338 | 318 |
| 339 startEdgePeek: function() { | 319 _startEdgePeek: function() { |
| 340 this.width = this.$.drawer.offsetWidth; | 320 this.width = this.$.drawer.offsetWidth; |
| 341 this.moveDrawer(this.translateXForDeltaX(this.rightDrawer ? | 321 this._moveDrawer(this._translateXForDeltaX(this.rightDrawer ? |
| 342 -this.edgeSwipeSensitivity : this.edgeSwipeSensitivity)); | 322 -this.edgeSwipeSensitivity : this.edgeSwipeSensitivity)); |
| 343 this.peeking = true; | 323 this.peeking = true; |
| 344 }, | 324 }, |
| 345 | 325 |
| 346 stopEdgePeek: function() { | 326 _stopEdgePeek: function() { |
| 347 if (this.peeking) { | 327 if (this.peeking) { |
| 348 this.peeking = false; | 328 this.peeking = false; |
| 349 this.moveDrawer(null); | 329 this._moveDrawer(null); |
| 350 } | 330 } |
| 351 }, | 331 }, |
| 352 | 332 |
| 353 _downHandler: function(e) { | 333 _downHandler: function(e) { |
| 354 if (!this.dragging && this._isMainSelected() && this._isEdgeTouch(e)) { | 334 if (!this.dragging && this._isMainSelected() && this._isEdgeTouch(e) &&
!sharedPanel) { |
| 355 this._startEdgePeek(); | 335 this._startEdgePeek(); |
| 336 // grab this panel |
| 337 sharedPanel = this; |
| 356 } | 338 } |
| 357 }, | 339 }, |
| 358 | 340 |
| 359 _upHandler: function(e) { | 341 _upHandler: function() { |
| 360 this._stopEdgePeek(); | 342 this._stopEdgePeek(); |
| 343 // release the panel |
| 344 sharedPanel = null; |
| 361 }, | 345 }, |
| 362 | 346 |
| 363 _onTap: function(e) { | 347 _onTap: function(e) { |
| 364 var targetElement = Polymer.dom(e).localTarget; | 348 var targetElement = Polymer.dom(e).localTarget; |
| 365 var isTargetToggleElement = targetElement && | 349 var isTargetToggleElement = targetElement && |
| 366 this.drawerToggleAttribute && | 350 this.drawerToggleAttribute && |
| 367 targetElement.hasAttribute(this.drawerToggleAttribute); | 351 targetElement.hasAttribute(this.drawerToggleAttribute); |
| 368 | 352 |
| 369 if (isTargetToggleElement) { | 353 if (isTargetToggleElement) { |
| 370 this.togglePanel(); | 354 this.togglePanel(); |
| 371 } | 355 } |
| 372 }, | 356 }, |
| 373 | 357 |
| 374 isEdgeTouch: function(event) { | 358 _isEdgeTouch: function(e) { |
| 375 var x = event.detail.x; | 359 var x = e.detail.x; |
| 376 | 360 |
| 377 return !this.disableEdgeSwipe && this.swipeAllowed() && | 361 return !this.disableEdgeSwipe && this._swipeAllowed() && |
| 378 (this.rightDrawer ? | 362 (this.rightDrawer ? |
| 379 x >= this.offsetWidth - this.edgeSwipeSensitivity : | 363 x >= this.offsetWidth - this.edgeSwipeSensitivity : |
| 380 x <= this.edgeSwipeSensitivity); | 364 x <= this.edgeSwipeSensitivity); |
| 381 }, | 365 }, |
| 382 | 366 |
| 383 trackStart: function(event) { | 367 _trackStart: function() { |
| 384 if (this.swipeAllowed()) { | 368 if (this._swipeAllowed()) { |
| 369 sharedPanel = this; |
| 385 this.dragging = true; | 370 this.dragging = true; |
| 386 this._startX = event.detail.x; | |
| 387 | 371 |
| 388 if (this.isMainSelected()) { | 372 if (this._isMainSelected()) { |
| 389 this.dragging = this.peeking || this.isEdgeTouch(event); | 373 this.dragging = this.peeking || this._isEdgeTouch(event); |
| 390 } | 374 } |
| 391 | 375 |
| 392 if (this.dragging) { | 376 if (this.dragging) { |
| 393 this.width = this.$.drawer.offsetWidth; | 377 this.width = this.$.drawer.offsetWidth; |
| 394 this.transition = false; | 378 this.transition = false; |
| 395 | |
| 396 // TODO: Re-enable when tap gestures are implemented. | |
| 397 // | |
| 398 // e.preventTap(); | |
| 399 } | 379 } |
| 400 } | 380 } |
| 401 }, | 381 }, |
| 402 | 382 |
| 403 translateXForDeltaX: function(deltaX) { | 383 _translateXForDeltaX: function(deltaX) { |
| 404 var isMain = this.isMainSelected(); | 384 var isMain = this._isMainSelected(); |
| 405 | 385 |
| 406 if (this.rightDrawer) { | 386 if (this.rightDrawer) { |
| 407 return Math.max(0, isMain ? this.width + deltaX : deltaX); | 387 return Math.max(0, isMain ? this.width + deltaX : deltaX); |
| 408 } else { | 388 } else { |
| 409 return Math.min(0, isMain ? deltaX - this.width : deltaX); | 389 return Math.min(0, isMain ? deltaX - this.width : deltaX); |
| 410 } | 390 } |
| 411 }, | 391 }, |
| 412 | 392 |
| 413 trackX: function(event) { | 393 _trackX: function(e) { |
| 414 var dx = event.detail.x - this._startX; | 394 if (this.dragging) { |
| 395 var dx = e.detail.dx; |
| 415 | 396 |
| 416 if (this.dragging) { | |
| 417 if (this.peeking) { | 397 if (this.peeking) { |
| 418 if (Math.abs(dx) <= this.edgeSwipeSensitivity) { | 398 if (Math.abs(dx) <= this.edgeSwipeSensitivity) { |
| 419 // Ignore trackx until we move past the edge peek. | 399 // Ignore trackx until we move past the edge peek. |
| 420 return; | 400 return; |
| 421 } | 401 } |
| 422 | |
| 423 this.peeking = false; | 402 this.peeking = false; |
| 424 } | 403 } |
| 425 | 404 |
| 426 this.moveDrawer(this.translateXForDeltaX(dx)); | 405 this._moveDrawer(this._translateXForDeltaX(dx)); |
| 427 } | 406 } |
| 428 }, | 407 }, |
| 429 | 408 |
| 430 trackEnd: function(event) { | 409 _trackEnd: function(e) { |
| 431 if (this.dragging) { | 410 if (this.dragging) { |
| 432 var xDirection = (event.detail.x - this._startX) > 0; | 411 var xDirection = e.detail.dx > 0; |
| 433 | 412 |
| 434 this.dragging = false; | 413 this.dragging = false; |
| 435 this._startX = null; | |
| 436 this.transition = true; | 414 this.transition = true; |
| 437 this.moveDrawer(null); | 415 sharedPanel = null; |
| 416 this._moveDrawer(null); |
| 438 | 417 |
| 439 if (this.rightDrawer) { | 418 if (this.rightDrawer) { |
| 440 this[(xDirection > 0) ? 'closeDrawer' : 'openDrawer'](); | 419 this[xDirection ? 'closeDrawer' : 'openDrawer'](); |
| 441 } else { | 420 } else { |
| 442 this[(xDirection > 0) ? 'openDrawer' : 'closeDrawer'](); | 421 this[xDirection ? 'openDrawer' : 'closeDrawer'](); |
| 443 } | 422 } |
| 444 } | 423 } |
| 445 }, | 424 }, |
| 446 | 425 |
| 447 transformForTranslateX: function(translateX) { | 426 _transformForTranslateX: function(translateX) { |
| 448 if (translateX === null) { | 427 if (translateX === null) { |
| 449 return ''; | 428 return ''; |
| 450 } | 429 } |
| 451 | 430 |
| 452 return this.hasWillChange ? 'translateX(' + translateX + 'px)' : | 431 return this.hasWillChange ? 'translateX(' + translateX + 'px)' : |
| 453 'translate3d(' + translateX + 'px, 0, 0)'; | 432 'translate3d(' + translateX + 'px, 0, 0)'; |
| 454 }, | 433 }, |
| 455 | 434 |
| 456 moveDrawer: function(translateX) { | 435 _moveDrawer: function(translateX) { |
| 457 var s = this.$.drawer.style; | 436 var s = this.$.drawer.style; |
| 458 | 437 |
| 459 if (this.hasTransform) { | 438 if (this.hasTransform) { |
| 460 s.transform = this.transformForTranslateX(translateX); | 439 s.transform = this._transformForTranslateX(translateX); |
| 461 } else { | 440 } else { |
| 462 s.webkitTransform = this.transformForTranslateX(translateX); | 441 s.webkitTransform = this._transformForTranslateX(translateX); |
| 463 } | 442 } |
| 464 } | 443 } |
| 465 | 444 |
| 466 }); | 445 }); |
| 467 | 446 |
| 468 }()); | 447 }()); |
| 469 | 448 |
| OLD | NEW |