in src/Clients/Web/winjs/js/winjs.js [33191:33287]
onPointerUp: function ItemEventsHandler_onPointerUp(eventObject) {
_WriteProfilerMark("WinJS.UI._ItemEventsHandler:MSPointerUp,StartTM");
var site = this._site;
this._skipClick = true;
var that = this;
var swipeEnabled = this._site.swipeBehavior === _UI.SwipeBehavior.select;
_BaseUtils._yieldForEvents(function () {
that._skipClick = false;
});
try {
// Release the pointer capture to allow in air touch pointers to be reused for multiple interactions
_ElementUtilities._releasePointerCapture(site.canvasProxy, eventObject.pointerId);
} catch (e) {
// This can throw if SeZo had capture or if the pointer was not already captured
}
var touchInput = (eventObject.pointerType === PT_TOUCH),
releasedElement = this._releasedElement(eventObject),
releasedIndex = site.indexForItemElement(releasedElement),
releasedHeaderIndex = releasedElement && _ElementUtilities.hasClass(releasedElement, _Constants._headerContainerClass) ? site.indexForHeaderElement(site.pressedHeader) : site.indexForHeaderElement(releasedElement);
if (this._pointerId === eventObject.pointerId) {
var releasedEntity;
if (releasedHeaderIndex === _Constants._INVALID_INDEX) {
releasedEntity = { type: _UI.ObjectType.item, index: releasedIndex };
} else {
releasedEntity = { type: _UI.ObjectType.groupHeader, index: releasedHeaderIndex };
}
this._resetPressedContainer();
if (this._site.pressedEntity.type === _UI.ObjectType.item && releasedEntity.type === _UI.ObjectType.item &&
this._site.pressedContainer && this._site.pressedEntity.index === releasedEntity.index) {
if (!eventObject.shiftKey) {
// Reset the shift selection pivot when the user clicks w/o pressing shift
site.selection._pivot = _Constants._INVALID_INDEX;
}
if (eventObject.shiftKey) {
// Shift selection should work when shift or shift+ctrl are depressed for both left- and right-click
if (this._selectionAllowed() && this._multiSelection() && site.selection._pivot !== _Constants._INVALID_INDEX) {
var firstIndex = Math.min(this._site.pressedEntity.index, site.selection._pivot),
lastIndex = Math.max(this._site.pressedEntity.index, site.selection._pivot),
additive = (this._pointerRightButton || eventObject.ctrlKey || site.tapBehavior === _UI.TapBehavior.toggleSelect);
site.selectRange(firstIndex, lastIndex, additive);
}
} else if (eventObject.ctrlKey || (this._selectionAllowed() && swipeEnabled && this._pointerRightButton)) {
// Swipe emulation
this.handleSwipeBehavior(this._site.pressedEntity.index);
}
}
if ((this._site.pressedHeader || this._site.pressedContainer) && this._swipeBehaviorState !== MSManipulationEventStates.MS_MANIPULATION_STATE_COMMITTED) {
var upPosition = _ElementUtilities._getCursorPos(eventObject);
var isTap = Math.abs(upPosition.left - this._site.pressedPosition.left) <= _Constants._TAP_END_THRESHOLD &&
Math.abs(upPosition.top - this._site.pressedPosition.top) <= _Constants._TAP_END_THRESHOLD;
this._endSelfRevealGesture();
this._clearItem(this._site.pressedEntity, this._isSelected(this._site.pressedEntity.index));
// We do not care whether or not the pressed and released indices are equivalent when the user is using touch. The only time they won't be is if the user
// tapped the edge of an item and the pressed animation shrank the item such that the user's finger was no longer over it. In this case, the item should
// be considered tapped.
// However, if the user is using touch then we must perform an extra check. Sometimes we receive MSPointerUp events when the user intended to pan or swipe.
// This extra check ensures that these intended pans/swipes aren't treated as taps.
if (!this._pointerRightButton && !this._pointerTriggeredSRG && !eventObject.ctrlKey && !eventObject.shiftKey &&
((touchInput && isTap) ||
(!touchInput && this._site.pressedEntity.index === releasedEntity.index && this._site.pressedEntity.type === releasedEntity.type))) {
if (releasedEntity.type === _UI.ObjectType.groupHeader) {
this._site.pressedHeader = site.headerAtIndex(releasedEntity.index);
this._site.pressedItemBox = null;
this._site.pressedContainer = null;
} else {
this._site.pressedItemBox = site.itemBoxAtIndex(releasedEntity.index);
this._site.pressedContainer = site.containerAtIndex(releasedEntity.index);
this._site.pressedHeader = null;
}
if (this._canTapSelect) {
this.handleTap(this._site.pressedEntity);
}
this._site.fireInvokeEvent(this._site.pressedEntity, this._site.pressedItemBox || this._site.pressedHeader);
}
}
if (this._site.pressedEntity.index !== _Constants._INVALID_INDEX) {
site.changeFocus(this._site.pressedEntity, true, false, true);
}
this.resetPointerDownState();
}
_WriteProfilerMark("WinJS.UI._ItemEventsHandler:MSPointerUp,StopTM");
},