Giter Club home page Giter Club logo

touche's People

Contributors

cbt1 avatar edvard-falkskar avatar haxxmaxx avatar magnuskenneth avatar nilzona avatar peol avatar stoffeastrom avatar t-wizard avatar veinfors avatar yoohahn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

touche's Issues

Handle MSPointer events

We need to handle MSPointer events.

If window.navigator.msPointerEnabled bind the MSPointerDown/MSPointerMove/MSPointerUp.
Set -ms-touch-action: none; for the binding element so the events gets directed to javascript code

How should we handle for example win8 with chrome where both mouse/touch events are fired

  • Start event should decide the gesture flow
  • Gesture should be type dependant. I.e for touch we need to support that you put first 1 finger down and then next.
    This would end up as a 2-finger tap.
  • If you use your mouse simultaneously it should be consider as another gesture
  • For MSPointer. could we distinguish type? Else it would feel weird to be able to do a 2-finger tap with the mouse and finger.

event.pointerType -> mouse, pen, touch

Introduce a getValidTarget

We need to introduce a getValidTarget which would traverse up the DOM until we have a "valid" element. That element should be set as relatedTarget. If we do T.utils.getRect for that valid element the gestures could use that instead of doing it themselves.

Maybe we also could introduce "selector". So it would traverse up to matched selector. If not matched it will not trigger

Add buildstep

We need to have a buildstep so we can keep an up-to-date touche.min.js for easy distribution.

activate buttons when pressing the space key

If you on desktop tab to a <button>, and press the spacekey, I would assume that a tap event would be triggered, but it isn't as of now.

Browsers apply the :active pseudo class so it seems logical.

Mouse down on scrollbar will not trigger mouseup

This is fixed in chrome canary (https://code.google.com/p/chromium/issues/detail?id=14204)
IE 10 still has the issue (https://connect.microsoft.com/IE/feedback/details/783058/scrollbar-trigger-mousedown-but-not-mouseup)

Don't know if we should do anything about this in Touché but we are aware of the issue.

One hack is to check if the event.target.scrollHeight > event.target.getBoundingClientRect().height for vertical scroll and vice versa for horizontal. If either is true the mousedown was on the scrollbar.

double tap

How should we handle double tap and cancellation of tap?

The double tap definition should handle this. Add the possibility to delay the tap from the double tap and either trigger double tap or the tap gesture

Clicking on scrollbar in IE11 starts swipe but never ends it

Given you have attached Touché with swipe to an element and you click on the scrollbar belonging to that element, swipe gets started by never ended (compared to clicking on the actual element, which also ends the swipe).

Test case:

<!DOCTYPE html>
<html>
<head>
    <style>
        .outer {
            height: 200px;
            width: 200px;
            overflow: auto;
            border: 1px solid gray;
        }

        .inner {
            height: 600px;
            width: 600px;
        }
    </style>
</head>
<body>

    <div class="outer">
        <div class="inner">inner</div>
    </div>

    <script src="touche.min.js"></script>
    <script>

        var element = document.getElementsByClassName("outer")[0];

        Touche( element ).swipe( {
            options: {
                preventDefault: false,
                radiusThreshold: 1
            },
            start: function ( nativeEvent, data ) {
                console.log("touche start");
            },
            update: function ( nativeEvent, data ) {
                console.log("touche update");
            },
            end: function ( nativeEvent, data ) {
                console.log("touche end");
            }
        } );

    </script>

</body>
</html>

New proposed syntax for defining gestures

Currently, there's a lot of overhead when defining a gesture. There's object merging for options, default empty callbacks and so on. I'd like to see a cleaner, more easily understood API for defining gestures.

Below is a proposed way of a cleaner API.

Touche.add('gesturename', {
    options: {},
    init: function() {},
    start: function() {},
    update: function() {},
    end: function() {},
    cancel: function() {}
});

init is the only required key in the gesture definition. All others (options, start, update, end, cancel) are optional.

  • options are defined default values, e.g. thresholds and so on that are specific to the gesture
  • init handles any logic that should be run when the gesture is bound to an element
  • start is triggered when the gesture manager of that element deems it appropriate to start the gesture
  • update is triggered whenever the gesture has been started and there's movement (either by finger, timer, mouse etc.)
  • end is triggered if the gesture successfully ended, this is what most people would want to use
  • cancel is triggered if the element's gesture manager has seen another gesture that has been fulfilled or if the user somehow cancelled the interaction (e.g. touchcancel or similar)

Let's open up a discussion around this so the API is simple to use.

Doubletap options

Double tap options is not used on the underlying tap gesture. The tap should get the doubletap options! I.e preventDefault:false should work.

Add possibility to prevent gestures

Instead of using event.stopPropagation() it would be nice to expose a function that prevent gestures with optional [exceptThisGestureHandler] parameter.

Looked into this.

The way to solve this would be to have an static function

T.preventGestures = function(excludeHandler) {
        T.cache.data.filter(function(obj) {
            return (excludeHandler ? obj.context !== excludeHandler : true);
        }).forEach(function(obj) {
            obj.context.prevented = true;
        });
};

and a check

        this.handleEvent = function(event) {
            var events = T.utils.getEvents(),
                flowType = T.utils.getFlowType(event.type);

            if(events.start.some(function(val) {
                return event.type === val;
            })) {
                if(this.isOtherFlowStarted(flowType)) {
                    return;
                }
                if(this.prevented) {
                    this.prevented = false;
                    return;
                }
//... left out

This way it would be possible to prevent gestures if needed.

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.