| OLD | NEW |
| 1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. | 1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. |
| 2 // limitations under the License. | 2 // limitations under the License. |
| 3 // See the License for the specific language governing permissions and | 3 // See the License for the specific language governing permissions and |
| 4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 5 // distributed under the License is distributed on an "AS-IS" BASIS, | 5 // distributed under the License is distributed on an "AS-IS" BASIS, |
| 6 // Unless required by applicable law or agreed to in writing, software | 6 // Unless required by applicable law or agreed to in writing, software |
| 7 // | 7 // |
| 8 // http://www.apache.org/licenses/LICENSE-2.0 | 8 // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 // | 9 // |
| 10 // You may obtain a copy of the License at | 10 // You may obtain a copy of the License at |
| 11 // you may not use this file except in compliance with the License. | 11 // you may not use this file except in compliance with the License. |
| 12 // Licensed under the Apache License, Version 2.0 (the "License"); | 12 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 13 // | 13 // |
| 14 goog.provide('i18n.input.chrome.inputview.handler.PointerActionBundle'); | 14 goog.provide('i18n.input.chrome.inputview.handler.PointerActionBundle'); |
| 15 | 15 |
| 16 goog.require('goog.Timer'); | 16 goog.require('goog.Timer'); |
| 17 goog.require('goog.dom'); | |
| 18 goog.require('goog.events.EventTarget'); | 17 goog.require('goog.events.EventTarget'); |
| 19 goog.require('goog.events.EventType'); | 18 goog.require('goog.events.EventType'); |
| 20 goog.require('goog.math.Coordinate'); | 19 goog.require('goog.math.Coordinate'); |
| 21 goog.require('i18n.input.chrome.inputview.SwipeDirection'); | 20 goog.require('i18n.input.chrome.inputview.SwipeDirection'); |
| 22 goog.require('i18n.input.chrome.inputview.events.DragEvent'); | 21 goog.require('i18n.input.chrome.inputview.events.DragEvent'); |
| 23 goog.require('i18n.input.chrome.inputview.events.EventType'); | 22 goog.require('i18n.input.chrome.inputview.events.EventType'); |
| 24 goog.require('i18n.input.chrome.inputview.events.PointerEvent'); | 23 goog.require('i18n.input.chrome.inputview.events.PointerEvent'); |
| 25 goog.require('i18n.input.chrome.inputview.events.SwipeEvent'); | 24 goog.require('i18n.input.chrome.inputview.events.SwipeEvent'); |
| 26 goog.require('i18n.input.chrome.inputview.handler.SwipeState'); | 25 goog.require('i18n.input.chrome.inputview.handler.SwipeState'); |
| 27 goog.require('i18n.input.chrome.inputview.handler.Util'); | 26 goog.require('i18n.input.chrome.inputview.handler.Util'); |
| 28 | 27 |
| 29 | 28 |
| 30 | 29 |
| 31 goog.scope(function() { | 30 goog.scope(function() { |
| 32 | 31 |
| 33 | 32 |
| 34 | 33 |
| 35 /** | 34 /** |
| 36 * The handler for long press. | 35 * The handler for long press. |
| 37 * | 36 * |
| 38 * @param {i18n.input.chrome.inputview.elements.Element} view The view for this | 37 * @param {!i18n.input.chrome.inputview.elements.Element} view The view for this |
| 39 * pointer event. | 38 * pointer event. |
| 40 * @param {goog.events.EventTarget=} opt_parentEventTarget The parent event | 39 * @param {goog.events.EventTarget=} opt_parentEventTarget The parent event |
| 41 * target. | 40 * target. |
| 42 * @constructor | 41 * @constructor |
| 43 * @extends {goog.events.EventTarget} | 42 * @extends {goog.events.EventTarget} |
| 44 */ | 43 */ |
| 45 i18n.input.chrome.inputview.handler.PointerActionBundle = function(view, | 44 i18n.input.chrome.inputview.handler.PointerActionBundle = function(view, |
| 46 opt_parentEventTarget) { | 45 opt_parentEventTarget) { |
| 47 goog.base(this); | 46 goog.base(this); |
| 48 this.setParentEventTarget(opt_parentEventTarget || null); | 47 this.setParentEventTarget(opt_parentEventTarget || null); |
| 49 | 48 |
| 50 /** | 49 /** |
| 51 * The target. | 50 * The target. |
| 52 * | 51 * |
| 53 * @type {i18n.input.chrome.inputview.elements.Element} | 52 * @type {!i18n.input.chrome.inputview.elements.Element} |
| 54 */ | 53 */ |
| 55 this.view = view; | 54 this.view = view; |
| 56 | 55 |
| 57 /** | 56 /** |
| 58 * The swipe offset. | 57 * The swipe offset. |
| 59 * | 58 * |
| 60 * @type {!i18n.input.chrome.inputview.handler.SwipeState} | 59 * @type {!i18n.input.chrome.inputview.handler.SwipeState} |
| 61 * @private | 60 * @private |
| 62 */ | 61 */ |
| 63 this.swipeState_ = new i18n.input.chrome.inputview.handler.SwipeState(); | 62 this.swipeState_ = new i18n.input.chrome.inputview.handler.SwipeState(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 */ | 148 */ |
| 150 PointerActionBundle.prototype.isFlickering_ = false; | 149 PointerActionBundle.prototype.isFlickering_ = false; |
| 151 | 150 |
| 152 | 151 |
| 153 /** | 152 /** |
| 154 * Handles touchmove event for one target. | 153 * Handles touchmove event for one target. |
| 155 * | 154 * |
| 156 * @param {!Touch | !Event} e . | 155 * @param {!Touch | !Event} e . |
| 157 */ | 156 */ |
| 158 PointerActionBundle.prototype.handlePointerMove = function(e) { | 157 PointerActionBundle.prototype.handlePointerMove = function(e) { |
| 158 var identifier = Util.getEventIdentifier(e); |
| 159 var direction = 0; | 159 var direction = 0; |
| 160 var deltaX = this.swipeState_.previousX == 0 ? 0 : (e.pageX - | 160 var deltaX = this.swipeState_.previousX == 0 ? 0 : (e.pageX - |
| 161 this.swipeState_.previousX); | 161 this.swipeState_.previousX); |
| 162 var deltaY = this.swipeState_.previousY == 0 ? 0 : | 162 var deltaY = this.swipeState_.previousY == 0 ? 0 : |
| 163 (e.pageY - this.swipeState_.previousY); | 163 (e.pageY - this.swipeState_.previousY); |
| 164 this.swipeState_.offsetX += deltaX; | 164 this.swipeState_.offsetX += deltaX; |
| 165 this.swipeState_.offsetY += deltaY; | 165 this.swipeState_.offsetY += deltaY; |
| 166 this.dispatchEvent(new i18n.input.chrome.inputview.events.DragEvent( | 166 this.dispatchEvent(new i18n.input.chrome.inputview.events.DragEvent( |
| 167 this.view, direction, /** @type {!Node} */ (e.target), | 167 this.view, direction, /** @type {!Node} */ (e.target), |
| 168 e.pageX, e.pageY, deltaX, deltaY)); | 168 e.pageX, e.pageY, deltaX, deltaY, identifier)); |
| 169 | 169 |
| 170 var minimumSwipeDist = PointerActionBundle. | 170 var minimumSwipeDist = PointerActionBundle. |
| 171 MINIMUM_SWIPE_DISTANCE_; | 171 MINIMUM_SWIPE_DISTANCE_; |
| 172 | 172 |
| 173 if (this.swipeState_.offsetX > minimumSwipeDist) { | 173 if (this.swipeState_.offsetX > minimumSwipeDist) { |
| 174 direction |= i18n.input.chrome.inputview.SwipeDirection.RIGHT; | 174 direction |= i18n.input.chrome.inputview.SwipeDirection.RIGHT; |
| 175 this.swipeState_.offsetX = 0; | 175 this.swipeState_.offsetX = 0; |
| 176 } else if (this.swipeState_.offsetX < -minimumSwipeDist) { | 176 } else if (this.swipeState_.offsetX < -minimumSwipeDist) { |
| 177 direction |= i18n.input.chrome.inputview.SwipeDirection.LEFT; | 177 direction |= i18n.input.chrome.inputview.SwipeDirection.LEFT; |
| 178 this.swipeState_.offsetX = 0; | 178 this.swipeState_.offsetX = 0; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 189 } | 189 } |
| 190 | 190 |
| 191 this.swipeState_.previousX = e.pageX; | 191 this.swipeState_.previousX = e.pageX; |
| 192 this.swipeState_.previousY = e.pageY; | 192 this.swipeState_.previousY = e.pageY; |
| 193 | 193 |
| 194 if (direction > 0) { | 194 if (direction > 0) { |
| 195 // If there is any movement, cancel the longpress timer. | 195 // If there is any movement, cancel the longpress timer. |
| 196 goog.Timer.clear(this.longPressTimer_); | 196 goog.Timer.clear(this.longPressTimer_); |
| 197 this.dispatchEvent(new i18n.input.chrome.inputview.events.SwipeEvent( | 197 this.dispatchEvent(new i18n.input.chrome.inputview.events.SwipeEvent( |
| 198 this.view, direction, /** @type {!Node} */ (e.target), | 198 this.view, direction, /** @type {!Node} */ (e.target), |
| 199 e.pageX, e.pageY)); | 199 e.pageX, e.pageY, identifier)); |
| 200 var currentTargetView = Util.getView(this.currentTarget_); | 200 var currentTargetView = Util.getView(this.currentTarget_); |
| 201 if (this.view) { | 201 this.isFlickering_ = !this.isLongPressing_ && !!(this.view.pointerConfig. |
| 202 this.isFlickering_ = !this.isLongPressing_ && !!(this.view.pointerConfig. | 202 flickerDirection & direction) && currentTargetView == this.view; |
| 203 flickerDirection & direction) && currentTargetView == this.view; | |
| 204 } | |
| 205 } | 203 } |
| 206 | 204 |
| 207 this.maybeSwitchTarget_(e); | 205 this.maybeSwitchTarget_( |
| 206 new goog.math.Coordinate(e.pageX, e.pageY), identifier); |
| 208 }; | 207 }; |
| 209 | 208 |
| 210 | 209 |
| 211 /** | 210 /** |
| 212 * If the target is switched to a new one, sends out a pointer_over for the new | 211 * If the target is switched to a new one, sends out a pointer_over for the new |
| 213 * target and sends out a pointer_out for the old target. | 212 * target and sends out a pointer_out for the old target. |
| 214 * | 213 * |
| 215 * @param {!Touch | !Event | !goog.events.BrowserEvent} e . | 214 * @param {!goog.math.Coordinate} pageOffset . |
| 215 * @param {number} identifier . |
| 216 * @private | 216 * @private |
| 217 */ | 217 */ |
| 218 PointerActionBundle.prototype.maybeSwitchTarget_ = function(e) { | 218 PointerActionBundle.prototype.maybeSwitchTarget_ = function(pageOffset, |
| 219 identifier) { |
| 219 if (!this.isFlickering_) { | 220 if (!this.isFlickering_) { |
| 220 var pageOffset = this.getPageOffset_(e); | |
| 221 var actualTarget = document.elementFromPoint(pageOffset.x, pageOffset.y); | 221 var actualTarget = document.elementFromPoint(pageOffset.x, pageOffset.y); |
| 222 var currentTargetView = Util.getView(this.currentTarget_); | 222 var currentTargetView = Util.getView(this.currentTarget_); |
| 223 var actualTargetView = Util.getView(actualTarget); | 223 var actualTargetView = Util.getView(actualTarget); |
| 224 if (currentTargetView != actualTargetView) { | 224 if (currentTargetView != actualTargetView) { |
| 225 if (currentTargetView) { | 225 if (currentTargetView) { |
| 226 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( | 226 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( |
| 227 currentTargetView, | 227 currentTargetView, |
| 228 i18n.input.chrome.inputview.events.EventType.POINTER_OUT, | 228 i18n.input.chrome.inputview.events.EventType.POINTER_OUT, |
| 229 this.currentTarget_, pageOffset.x, pageOffset.y)); | 229 this.currentTarget_, pageOffset.x, pageOffset.y, identifier)); |
| 230 } | 230 } |
| 231 if (actualTargetView) { | 231 if (actualTargetView) { |
| 232 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( | 232 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( |
| 233 actualTargetView, | 233 actualTargetView, |
| 234 i18n.input.chrome.inputview.events.EventType.POINTER_OVER, | 234 i18n.input.chrome.inputview.events.EventType.POINTER_OVER, |
| 235 actualTarget, pageOffset.x, pageOffset.y)); | 235 actualTarget, pageOffset.x, pageOffset.y, identifier)); |
| 236 } | 236 } |
| 237 this.currentTarget_ = actualTarget; | 237 this.currentTarget_ = actualTarget; |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 }; | 240 }; |
| 241 | 241 |
| 242 | 242 |
| 243 /** | 243 /** |
| 244 * Handles pointer up, e.g., mouseup/touchend. | 244 * Handles pointer up, e.g., mouseup/touchend. |
| 245 * | 245 * |
| 246 * @param {!goog.events.BrowserEvent} e The event. | 246 * @param {!goog.events.BrowserEvent} e The event. |
| 247 */ | 247 */ |
| 248 PointerActionBundle.prototype.handlePointerUp = function(e) { | 248 PointerActionBundle.prototype.handlePointerUp = function(e) { |
| 249 goog.Timer.clear(this.longPressTimer_); | 249 goog.Timer.clear(this.longPressTimer_); |
| 250 var pageOffset = this.getPageOffset_(e); | 250 var pageOffset = this.getPageOffset_(e); |
| 251 var identifier = Util.getEventIdentifier(e); |
| 251 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( | 252 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( |
| 252 this.view, i18n.input.chrome.inputview.events.EventType.LONG_PRESS_END, | 253 this.view, i18n.input.chrome.inputview.events.EventType.LONG_PRESS_END, |
| 253 e.target, pageOffset.x, pageOffset.y)); | 254 e.target, pageOffset.x, pageOffset.y, identifier)); |
| 254 if (this.isDBLClicking_) { | 255 if (this.isDBLClicking_) { |
| 255 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( | 256 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( |
| 256 this.view, i18n.input.chrome.inputview.events.EventType. | 257 this.view, i18n.input.chrome.inputview.events.EventType. |
| 257 DOUBLE_CLICK_END, e.target, pageOffset.x, pageOffset.y)); | 258 DOUBLE_CLICK_END, e.target, pageOffset.x, pageOffset.y, identifier)); |
| 258 } else if (!(this.isLongPressing_ && this.view.pointerConfig. | 259 } else if (!(this.isLongPressing_ && this.view.pointerConfig. |
| 259 longPressWithoutPointerUp)) { | 260 longPressWithoutPointerUp)) { |
| 260 this.maybeSwitchTarget_(e); | 261 this.maybeSwitchTarget_(pageOffset, identifier); |
| 261 var view = Util.getView(this.currentTarget_); | 262 var view = Util.getView(this.currentTarget_); |
| 262 var target = this.currentTarget_; | 263 var target = this.currentTarget_; |
| 263 if (this.isFlickering_) { | 264 if (this.isFlickering_) { |
| 264 view = this.view; | 265 view = this.view; |
| 265 target = e.target; | 266 target = e.target; |
| 266 } | 267 } |
| 267 this.pointerUpTimeStamp_ = new Date().getTime(); | 268 this.pointerUpTimeStamp_ = new Date().getTime(); |
| 268 // Note |view| can be null if the finger moves outside of keyboard window | 269 // Note |view| can be null if the finger moves outside of keyboard window |
| 269 // area. This is possible when user try to select an accent character | 270 // area. This is possible when user try to select an accent character |
| 270 // which is displayed outside of keyboard window. We need to dispatch a | 271 // which is displayed outside of keyboard window. We need to dispatch a |
| 271 // POINTER_UP event to keyboard to commit the selected accent character. | 272 // POINTER_UP event to keyboard to commit the selected accent character. |
| 272 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( | 273 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( |
| 273 view, i18n.input.chrome.inputview.events.EventType.POINTER_UP, | 274 view, i18n.input.chrome.inputview.events.EventType.POINTER_UP, |
| 274 target, pageOffset.x, pageOffset.y, this.pointerUpTimeStamp_)); | 275 target, pageOffset.x, pageOffset.y, identifier, |
| 276 this.pointerUpTimeStamp_)); |
| 275 } | 277 } |
| 276 if (Util.getView(this.currentTarget_) == this.view) { | 278 if (Util.getView(this.currentTarget_) == this.view) { |
| 277 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( | 279 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( |
| 278 this.view, i18n.input.chrome.inputview.events.EventType.CLICK, | 280 this.view, i18n.input.chrome.inputview.events.EventType.CLICK, |
| 279 e.target, pageOffset.x, pageOffset.y)); | 281 e.target, pageOffset.x, pageOffset.y, identifier)); |
| 280 } | 282 } |
| 281 this.isDBLClicking_ = false; | 283 this.isDBLClicking_ = false; |
| 282 this.isLongPressing_ = false; | 284 this.isLongPressing_ = false; |
| 283 this.isFlickering_ = false; | 285 this.isFlickering_ = false; |
| 284 this.swipeState_.reset(); | 286 this.swipeState_.reset(); |
| 285 }; | 287 }; |
| 286 | 288 |
| 287 | 289 |
| 288 /** | 290 /** |
| 289 * Cancel double click recognition on this target. | 291 * Cancel double click recognition on this target. |
| 290 */ | 292 */ |
| 291 PointerActionBundle.prototype.cancelDoubleClick = function() { | 293 PointerActionBundle.prototype.cancelDoubleClick = function() { |
| 292 this.pointerDownTimeStamp_ = 0; | 294 this.pointerDownTimeStamp_ = 0; |
| 293 }; | 295 }; |
| 294 | 296 |
| 295 | 297 |
| 296 /** | 298 /** |
| 297 * Handles pointer down, e.g., mousedown/touchstart. | 299 * Handles pointer down, e.g., mousedown/touchstart. |
| 298 * | 300 * |
| 299 * @param {!goog.events.BrowserEvent} e The event. | 301 * @param {!goog.events.BrowserEvent} e The event. |
| 300 */ | 302 */ |
| 301 PointerActionBundle.prototype.handlePointerDown = function(e) { | 303 PointerActionBundle.prototype.handlePointerDown = function(e) { |
| 302 this.currentTarget_ = e.target; | 304 this.currentTarget_ = e.target; |
| 303 goog.Timer.clear(this.longPressTimer_); | 305 goog.Timer.clear(this.longPressTimer_); |
| 304 if (e.type != goog.events.EventType.MOUSEDOWN) { | 306 var identifier = Util.getEventIdentifier(e); |
| 305 // Don't trigger long press for mouse event. | 307 if (e.type == goog.events.EventType.TOUCHSTART) { |
| 306 this.maybeTriggerKeyDownLongPress_(e); | 308 this.maybeTriggerKeyDownLongPress_(e, identifier); |
| 307 } | 309 } |
| 308 this.maybeHandleDBLClick_(e); | 310 this.maybeHandleDBLClick_(e, identifier); |
| 309 if (!this.isDBLClicking_) { | 311 if (!this.isDBLClicking_) { |
| 310 var pageOffset = this.getPageOffset_(e); | 312 var pageOffset = this.getPageOffset_(e); |
| 311 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( | 313 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( |
| 312 this.view, i18n.input.chrome.inputview.events.EventType.POINTER_DOWN, | 314 this.view, i18n.input.chrome.inputview.events.EventType.POINTER_DOWN, |
| 313 e.target, pageOffset.x, pageOffset.y, this.pointerDownTimeStamp_)); | 315 e.target, pageOffset.x, pageOffset.y, identifier, |
| 316 this.pointerDownTimeStamp_)); |
| 314 } | 317 } |
| 315 }; | 318 }; |
| 316 | 319 |
| 317 | 320 |
| 318 /** | 321 /** |
| 319 * Gets the page offset from the event which may be mouse event or touch event. | 322 * Gets the page offset from the event which may be mouse event or touch event. |
| 320 * | 323 * |
| 321 * @param {!goog.events.BrowserEvent | !Touch | !Event} e . | 324 * @param {!goog.events.BrowserEvent} e . |
| 322 * @return {!goog.math.Coordinate} . | 325 * @return {!goog.math.Coordinate} . |
| 323 * @private | 326 * @private |
| 324 */ | 327 */ |
| 325 PointerActionBundle.prototype.getPageOffset_ = function(e) { | 328 PointerActionBundle.prototype.getPageOffset_ = function(e) { |
| 326 if (e.pageX && e.pageY) { | |
| 327 return new goog.math.Coordinate(e.pageX, e.pageY); | |
| 328 } | |
| 329 | |
| 330 if (!e.getBrowserEvent) { | |
| 331 return new goog.math.Coordinate(0, 0); | |
| 332 } | |
| 333 | |
| 334 var nativeEvt = e.getBrowserEvent(); | 329 var nativeEvt = e.getBrowserEvent(); |
| 335 if (nativeEvt.pageX && nativeEvt.pageY) { | 330 if (nativeEvt.pageX && nativeEvt.pageY) { |
| 336 return new goog.math.Coordinate(nativeEvt.pageX, nativeEvt.pageY); | 331 return new goog.math.Coordinate(nativeEvt.pageX, nativeEvt.pageY); |
| 337 } | 332 } |
| 338 | 333 |
| 339 | 334 |
| 340 var touchEventList = nativeEvt['changedTouches']; | 335 var touchEventList = nativeEvt['changedTouches']; |
| 341 if (!touchEventList || touchEventList.length == 0) { | 336 if (!touchEventList || touchEventList.length == 0) { |
| 342 touchEventList = nativeEvt['touches']; | 337 touchEventList = nativeEvt['touches']; |
| 343 } | 338 } |
| 344 if (touchEventList && touchEventList.length > 0) { | 339 if (touchEventList && touchEventList.length > 0) { |
| 345 var touchEvent = touchEventList[0]; | 340 var touchEvent = touchEventList[0]; |
| 346 return new goog.math.Coordinate(touchEvent.pageX, touchEvent.pageY); | 341 return new goog.math.Coordinate(touchEvent.pageX, touchEvent.pageY); |
| 347 } | 342 } |
| 348 | 343 |
| 349 return new goog.math.Coordinate(0, 0); | 344 return new goog.math.Coordinate(0, 0); |
| 350 }; | 345 }; |
| 351 | 346 |
| 352 | 347 |
| 353 /** | 348 /** |
| 354 * Maybe triggers the long press timer when pointer down. | 349 * Maybe triggers the long press timer when pointer down. |
| 355 * | 350 * |
| 356 * @param {!goog.events.BrowserEvent} e The event. | 351 * @param {!goog.events.BrowserEvent} e The event. |
| 352 * @param {number} identifier . |
| 357 * @private | 353 * @private |
| 358 */ | 354 */ |
| 359 PointerActionBundle.prototype.maybeTriggerKeyDownLongPress_ = function(e) { | 355 PointerActionBundle.prototype.maybeTriggerKeyDownLongPress_ = function(e, |
| 356 identifier) { |
| 360 if (this.view && (this.view.pointerConfig.longPressWithPointerUp || | 357 if (this.view && (this.view.pointerConfig.longPressWithPointerUp || |
| 361 this.view.pointerConfig.longPressWithoutPointerUp)) { | 358 this.view.pointerConfig.longPressWithoutPointerUp)) { |
| 362 this.longPressTimer_ = goog.Timer.callOnce( | 359 this.longPressTimer_ = goog.Timer.callOnce( |
| 363 goog.bind(this.triggerLongPress_, this, e), | 360 goog.bind(this.triggerLongPress_, this, e, identifier), |
| 364 this.view.pointerConfig.longPressDelay, this); | 361 this.view.pointerConfig.longPressDelay, this); |
| 365 } | 362 } |
| 366 }; | 363 }; |
| 367 | 364 |
| 368 | 365 |
| 369 /** | 366 /** |
| 370 * Maybe handle the double click. | 367 * Maybe handle the double click. |
| 371 * | 368 * |
| 372 * @param {!goog.events.BrowserEvent} e . | 369 * @param {!goog.events.BrowserEvent} e . |
| 370 * @param {number} identifier . |
| 373 * @private | 371 * @private |
| 374 */ | 372 */ |
| 375 PointerActionBundle.prototype.maybeHandleDBLClick_ = function(e) { | 373 PointerActionBundle.prototype.maybeHandleDBLClick_ = function(e, identifier) { |
| 376 if (this.view && this.view.pointerConfig.dblClick) { | 374 if (this.view && this.view.pointerConfig.dblClick) { |
| 377 var timeInMs = new Date().getTime(); | 375 var timeInMs = new Date().getTime(); |
| 378 var interval = this.view.pointerConfig.dblClickDelay || | 376 var interval = this.view.pointerConfig.dblClickDelay || |
| 379 PointerActionBundle.DOUBLE_CLICK_INTERVAL_; | 377 PointerActionBundle.DOUBLE_CLICK_INTERVAL_; |
| 380 var nativeEvt = e.getBrowserEvent(); | 378 var nativeEvt = e.getBrowserEvent(); |
| 381 if ((timeInMs - this.pointerDownTimeStamp_) < interval) { | 379 if ((timeInMs - this.pointerDownTimeStamp_) < interval) { |
| 382 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( | 380 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( |
| 383 this.view, i18n.input.chrome.inputview.events.EventType.DOUBLE_CLICK, | 381 this.view, i18n.input.chrome.inputview.events.EventType.DOUBLE_CLICK, |
| 384 e.target, nativeEvt.pageX, nativeEvt.pageY)); | 382 e.target, nativeEvt.pageX, nativeEvt.pageY, identifier)); |
| 385 this.isDBLClicking_ = true; | 383 this.isDBLClicking_ = true; |
| 386 } | 384 } |
| 387 this.pointerDownTimeStamp_ = timeInMs; | 385 this.pointerDownTimeStamp_ = timeInMs; |
| 388 } | 386 } |
| 389 }; | 387 }; |
| 390 | 388 |
| 391 | 389 |
| 392 /** | 390 /** |
| 393 * Triggers long press event. | 391 * Triggers long press event. |
| 394 * | 392 * |
| 395 * @param {!goog.events.BrowserEvent} e The event. | 393 * @param {!goog.events.BrowserEvent} e The event. |
| 394 * @param {number} identifier . |
| 396 * @private | 395 * @private |
| 397 */ | 396 */ |
| 398 PointerActionBundle.prototype.triggerLongPress_ = function(e) { | 397 PointerActionBundle.prototype.triggerLongPress_ = function(e, identifier) { |
| 399 var nativeEvt = e.getBrowserEvent(); | 398 var nativeEvt = e.getBrowserEvent(); |
| 400 if (nativeEvt.touches.length > 1) { | 399 if (nativeEvt.touches.length > 1) { |
| 401 return; | 400 return; |
| 402 } | 401 } |
| 403 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( | 402 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent( |
| 404 this.view, i18n.input.chrome.inputview.events.EventType.LONG_PRESS, | 403 this.view, i18n.input.chrome.inputview.events.EventType.LONG_PRESS, |
| 405 e.target, nativeEvt.pageX, nativeEvt.pageY)); | 404 e.target, nativeEvt.pageX, nativeEvt.pageY, identifier)); |
| 406 this.isLongPressing_ = true; | 405 this.isLongPressing_ = true; |
| 407 }; | 406 }; |
| 408 | 407 |
| 409 | 408 |
| 410 /** @override */ | 409 /** @override */ |
| 411 PointerActionBundle.prototype.disposeInternal = function() { | 410 PointerActionBundle.prototype.disposeInternal = function() { |
| 412 goog.dispose(this.longPressTimer_); | 411 goog.dispose(this.longPressTimer_); |
| 413 | 412 |
| 414 goog.base(this, 'disposeInternal'); | 413 goog.base(this, 'disposeInternal'); |
| 415 }; | 414 }; |
| 416 | 415 |
| 417 }); // goog.scope | 416 }); // goog.scope |
| OLD | NEW |