aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/ui/composer/press-composer.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage/ui/composer/press-composer.js')
-rw-r--r--node_modules/montage/ui/composer/press-composer.js52
1 files changed, 33 insertions, 19 deletions
diff --git a/node_modules/montage/ui/composer/press-composer.js b/node_modules/montage/ui/composer/press-composer.js
index d71d2ec6..55903b5f 100644
--- a/node_modules/montage/ui/composer/press-composer.js
+++ b/node_modules/montage/ui/composer/press-composer.js
@@ -58,9 +58,9 @@ var PressComposer = exports.PressComposer = Montage.create(Composer,/** @lends m
58 load: { 58 load: {
59 value: function() { 59 value: function() {
60 if (window.Touch) { 60 if (window.Touch) {
61 this._element.addEventListener("touchstart", this); 61 this._element.addEventListener("touchstart", this, true);
62 } else { 62 } else {
63 this._element.addEventListener("mousedown", this); 63 this._element.addEventListener("mousedown", this, true);
64 } 64 }
65 } 65 }
66 }, 66 },
@@ -76,6 +76,19 @@ var PressComposer = exports.PressComposer = Montage.create(Composer,/** @lends m
76 }, 76 },
77 77
78 /** 78 /**
79 Delegate that implements <code>surrenderPointer</code>. See Component for
80 explanation of what this method should do.
81
82 @type {Object}
83 @default null
84 */
85 delegate: {
86 serializable: true,
87 value: null
88 },
89
90
91 /**
79 Cancel the current press. 92 Cancel the current press.
80 93
81 Can be used in a "longPress" event handler to prevent the "press" event 94 Can be used in a "longPress" event handler to prevent the "press" event
@@ -191,16 +204,16 @@ var PressComposer = exports.PressComposer = Montage.create(Composer,/** @lends m
191 return false; 204 return false;
192 } 205 }
193 206
194 document.addEventListener("touchend", this); 207 document.addEventListener("touchend", this, false);
195 document.addEventListener("touchcancel", this); 208 document.addEventListener("touchcancel", this, false);
196 } else if (event.type === "mousedown") { 209 } else if (event.type === "mousedown") {
197 this._observedPointer = "mouse"; 210 this._observedPointer = "mouse";
198 // Needed to cancel action event dispatch is mouseup'd when 211 // Needed to cancel action event dispatch is mouseup'd when
199 // not on the component 212 // not on the component
200 document.addEventListener("mouseup", this); 213 document.addEventListener("mouseup", this, false);
201 // Needed to preventDefault if another component has claimed 214 // Needed to preventDefault if another component has claimed
202 // the pointer 215 // the pointer
203 document.addEventListener("click", this); 216 document.addEventListener("click", this, false);
204 } 217 }
205 218
206 this.component.eventManager.claimPointer(this._observedPointer, this); 219 this.component.eventManager.claimPointer(this._observedPointer, this);
@@ -239,18 +252,19 @@ var PressComposer = exports.PressComposer = Montage.create(Composer,/** @lends m
239 // in surrenderPointer, just end the interaction. 252 // in surrenderPointer, just end the interaction.
240 this._endInteraction(event); 253 this._endInteraction(event);
241 return; 254 return;
242 } 255 } else if (event.type === "mouseup") {
243
244 if (!isSurrendered && isTarget && event.type === "mouseup") {
245 this._dispatchPress(event);
246 this._endInteraction(event);
247 return;
248 }
249 256
250 if (!isSurrendered && !isTarget && event.type === "mouseup") { 257 if (!isSurrendered && isTarget) {
251 this._dispatchPressCancel(event); 258 this._dispatchPress(event);
252 this._endInteraction(event); 259 this._endInteraction(event);
253 return; 260 return;
261 } else if (!isSurrendered && !isTarget) {
262 this._dispatchPressCancel(event);
263 this._endInteraction(event);
264 return;
265 } else if (isSurrendered && !isTarget) {
266 this._endInteraction(event);
267 }
254 } 268 }
255 } 269 }
256 }, 270 },
@@ -319,7 +333,7 @@ var PressComposer = exports.PressComposer = Montage.create(Composer,/** @lends m
319 333
320 // Handlers 334 // Handlers
321 335
322 handleTouchstart: { 336 captureTouchstart: {
323 value: function(event) { 337 value: function(event) {
324 this._startInteraction(event); 338 this._startInteraction(event);
325 } 339 }
@@ -352,7 +366,7 @@ var PressComposer = exports.PressComposer = Montage.create(Composer,/** @lends m
352 } 366 }
353 }, 367 },
354 368
355 handleMousedown: { 369 captureMousedown: {
356 value: function(event) { 370 value: function(event) {
357 this._startInteraction(event); 371 this._startInteraction(event);
358 } 372 }