Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Side by Side Diff: chrome/browser/resources/settings/device_page/drag_behavior.js

Issue 2651483002: MD Settings: Eliminate use of ES6 for Chrome OS (Closed)
Patch Set: Feedback Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Behavior for handling dragging elements in a container. 6 * @fileoverview Behavior for handling dragging elements in a container.
7 * Draggable elements must have the 'draggable' attribute set. 7 * Draggable elements must have the 'draggable' attribute set.
8 */ 8 */
9 9
10 /** 10 /**
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 this.container_ = opt_container; 74 this.container_ = opt_container;
75 75
76 this.addListeners_(); 76 this.addListeners_();
77 77
78 if (opt_callback !== undefined) 78 if (opt_callback !== undefined)
79 this.callback_ = opt_callback; 79 this.callback_ = opt_callback;
80 }, 80 },
81 81
82 /** @private */ 82 /** @private */
83 addListeners_: function() { 83 addListeners_: function() {
84 let container = this.container_; 84 var container = this.container_;
85 if (!container || this.mouseDownListener_) 85 if (!container || this.mouseDownListener_)
86 return; 86 return;
87 this.mouseDownListener_ = this.onMouseDown_.bind(this); 87 this.mouseDownListener_ = this.onMouseDown_.bind(this);
88 container.addEventListener('mousedown', this.mouseDownListener_); 88 container.addEventListener('mousedown', this.mouseDownListener_);
89 89
90 this.mouseMoveListener_ = this.onMouseMove_.bind(this); 90 this.mouseMoveListener_ = this.onMouseMove_.bind(this);
91 container.addEventListener('mousemove', this.mouseMoveListener_); 91 container.addEventListener('mousemove', this.mouseMoveListener_);
92 92
93 this.touchStartListener_ = this.onTouchStart_.bind(this); 93 this.touchStartListener_ = this.onTouchStart_.bind(this);
94 container.addEventListener('touchstart', this.touchStartListener_); 94 container.addEventListener('touchstart', this.touchStartListener_);
95 95
96 this.touchMoveListener_ = this.onTouchMove_.bind(this); 96 this.touchMoveListener_ = this.onTouchMove_.bind(this);
97 container.addEventListener('touchmove', this.touchMoveListener_); 97 container.addEventListener('touchmove', this.touchMoveListener_);
98 98
99 this.endDragListener_ = this.endDrag_.bind(this); 99 this.endDragListener_ = this.endDrag_.bind(this);
100 window.addEventListener('mouseup', this.endDragListener_); 100 window.addEventListener('mouseup', this.endDragListener_);
101 container.addEventListener('touchend', this.endDragListener_); 101 container.addEventListener('touchend', this.endDragListener_);
102 }, 102 },
103 103
104 /** @private */ 104 /** @private */
105 removeListeners_: function() { 105 removeListeners_: function() {
106 let container = this.container_; 106 var container = this.container_;
107 if (!container || !this.mouseDownListener_) 107 if (!container || !this.mouseDownListener_)
108 return; 108 return;
109 container.removeEventListener('mousedown', this.mouseDownListener_); 109 container.removeEventListener('mousedown', this.mouseDownListener_);
110 this.mouseDownListener_ = null; 110 this.mouseDownListener_ = null;
111 container.removeEventListener('mousemove', this.mouseMoveListener_); 111 container.removeEventListener('mousemove', this.mouseMoveListener_);
112 this.mouseMoveListener_ = null; 112 this.mouseMoveListener_ = null;
113 container.removeEventListener('touchstart', this.touchStartListener_); 113 container.removeEventListener('touchstart', this.touchStartListener_);
114 this.touchStartListener_ = null; 114 this.touchStartListener_ = null;
115 container.removeEventListener('touchmove', this.touchMoveListener_); 115 container.removeEventListener('touchmove', this.touchMoveListener_);
116 this.touchMoveListener_ = null; 116 this.touchMoveListener_ = null;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 if (this.callback_) { 223 if (this.callback_) {
224 var delta = { 224 var delta = {
225 x: eventLocation.x - this.dragStartLocation_.x, 225 x: eventLocation.x - this.dragStartLocation_.x,
226 y: eventLocation.y - this.dragStartLocation_.y, 226 y: eventLocation.y - this.dragStartLocation_.y,
227 }; 227 };
228 this.callback_(this.dragId_, delta); 228 this.callback_(this.dragId_, delta);
229 } 229 }
230 return false; 230 return false;
231 }, 231 },
232 }; 232 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698