Git Product home page Git Product logo

Comments (1)

9bitStudios avatar 9bitStudios commented on August 13, 2024

I just pushed out an update to the CSS that gives the container a height. You'll want to pull that down. Now because the container actually has some dimensions to it you can attach your own touch event handler to determine if it is left or right (either in the "loaded" callback or immediately after calling the plugin).

var touchHandler = {

    xDown: null,
    yDown: null,
    handleTouchStart: function(evt) {                                         
        this.xDown = evt.touches[0].clientX;                                      
        this.yDown = evt.touches[0].clientY;
    }, 
    handleTouchMove: function (evt) {
        if (!this.xDown || !this.yDown) {
            return;
        }

        var xUp = evt.touches[0].clientX;                                    
        var yUp = evt.touches[0].clientY;

        var xDiff = this.xDown - xUp;
        var yDiff = this.yDown - yUp;
        
        // only comparing xDiff
        // compare which is greater against yDiff to determine whether left/right or up/down  e.g. if (Math.abs( xDiff ) > Math.abs( yDiff ))
        if (Math.abs( xDiff ) > 0) {
            if ( xDiff > 0 ) {
                // swipe left
                console.log("left")
            } else {
                //swipe right
                console.log("right")
            }                       
        }
        
        /* reset values */
        this.xDown = null;
        this.yDown = null;
        canNavigate = true;
    }
}

document.getElementById("flexiselDemo1").addEventListener('touchstart', touchHandler.handleTouchStart, false);        
document.getElementById("flexiselDemo1").addEventListener('touchmove', touchHandler.handleTouchMove, false);

from flexisel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.