1 EVENTS Touch
Sven Minio edited this page 2026-05-17 20:00:21 +02:00

.touchstart

Description Bind an event handler to the "touchstart" event (finger is placed on a touch surface).

Parameters

  • handler (Function, optional): Function to execute.

Returns

  • (jBase): Current instance.

Example

$('.swipe-area').touchstart(function(e) {
    console.log('Touch started');
});


.touchend

Description Bind an event handler to the "touchend" event (finger is removed from a touch surface).

Parameters

  • handler (Function, optional): Function to execute.

Returns

  • (jBase): Current instance.

Example

$('.swipe-area').touchend(function(e) {
    console.log('Touch ended');
});


.touchmove

Description Bind an event handler to the "touchmove" event (finger is dragged across the surface).

Parameters

  • handler (Function, optional): Function to execute.

Returns

  • (jBase): Current instance.

Example

$('.swipe-area').touchmove(function(e) {
    // prevent scrolling while swiping
    e.preventDefault(); 
});


.touchcancel

Description Bind an event handler to the "touchcancel" event (system cancels the touch event).

Parameters

  • handler (Function, optional): Function to execute.

Returns

  • (jBase): Current instance.

Example

$('.swipe-area').touchcancel(function() {
    console.log('Touch cancelled');
});


.swipeLeft

Description Binds an event handler to be executed when the user swipes their finger to the left across the element. The swipe must cover a minimum distance of 50px.

Parameters

  • handler (Function): Function to execute on left swipe.

Returns

  • (jBase): Current instance.

Example

$('.carousel').swipeLeft(() => nextSlide());

.swipeRight

Description Binds an event handler to be executed when the user swipes their finger to the right across the element.

Parameters

  • handler (Function): Function to execute on right swipe.

Returns

  • (jBase): Current instance.

Example

$('.carousel').swipeRight(() => prevSlide());

.swipeUp

Description Binds an event handler to be executed when the user swipes their finger upwards across the element.

Parameters

  • handler (Function): Function to execute on upward swipe.

Returns

  • (jBase): Current instance.

Example

$('.carousel').swipeUp(() => {
    CloseWindow()
});

.swipeDown

Description Binds an event handler to be executed when the user swipes their finger downwards across the element.

Parameters

  • handler (Function): Function to execute on downward swipe.

Returns

  • (jBase): Current instance.

Example

$('.carousel').swipeDown(() => {
    Reload();
});