MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / onEnd

Method onEnd

core/src/components/range/range.tsx:558–595  ·  view source on GitHub ↗

* The value should be updated on touch end: * - When the user lifts their finger from the screen after * tapping the bar. * * @param detail The details of the gesture or mouse event.

(detail: GestureDetail | MouseEvent)

Source from the content-addressed store, hash-verified

556 * @param detail The details of the gesture or mouse event.
557 */
558 private onEnd(detail: GestureDetail | MouseEvent) {
559 const { contentEl, initialContentScrollY } = this;
560 const currentX = (detail as GestureDetail).currentX ?? (detail as MouseEvent).clientX;
561
562 /**
563 * The `pressedKnob` can be undefined if the user never
564 * dragged the knob. They just tapped on the bar.
565 *
566 * This is necessary to determine which knob the user is changing,
567 * especially when using dual knobs.
568 * Plus, it determines when to apply certain styles.
569 */
570 if (this.pressedKnob === undefined) {
571 this.setPressedKnob(currentX);
572 }
573
574 /**
575 * The user is no longer dragging the bar or
576 * knob (if they were dragging it).
577 *
578 * The user can now scroll on the view in the next gesture event.
579 */
580 if (contentEl && this.pressedKnob !== undefined) {
581 resetContentScrollY(contentEl, initialContentScrollY);
582 }
583
584 // update the active knob's position
585 this.update(currentX);
586
587 /**
588 * Reset the pressed knob to undefined since the user
589 * may start dragging a different knob in the next gesture event.
590 */
591 this.pressedKnob = undefined;
592
593 this.emitValueChange();
594 this.ionKnobMoveEnd.emit({ value: this.ensureValueInBounds(this.value) });
595 }
596
597 private update(currentX: number) {
598 // figure out where the pointer is currently at

Callers 2

RangeClass · 0.95
renderRangeSliderMethod · 0.95

Calls 4

setPressedKnobMethod · 0.95
updateMethod · 0.95
emitValueChangeMethod · 0.95
resetContentScrollYFunction · 0.90

Tested by

no test coverage detected