Audentio / peapod

Peapod
3 stars 1 forks source link

Mouse/Touch events #2

Open tushar-singh opened 8 years ago

tushar-singh commented 8 years ago

We'll need something to allow easily attaching functions to mouse/tap/gestures

I'm aiming for a clean implementation. Something like this (using HOC to modify all components from wrapper.jsx)

eventHandler = function(e){
    //e.eventName might be an array (e.g. [mouseup,click]) 
    //so we use a function to check against one eventName
    if(e.is('mouseup')) 
        console.log(e.target)
},

render: function() {
    return (
        <Icon>home</Icon>
    )
}

I'm not entirely sure if this is feasible - will update once I make an attempt

If someone knows a good library (with a permissive licence), please share

mikecreuzer commented 8 years ago

You only need touch events some times. And it'd be case by case, just like we do click case by case, no?

tushar-singh commented 8 years ago

Doing it case-by-case will probably be hard to maintain down the line

And who knows, we might use touch events for a lot of stuff. Off the top my head - carousel, offcanvas, alerts(?). I'll revisit this and see whats best given the changes since I created this issue

mikecreuzer commented 8 years ago

Yeah I think you're right, I wasnt sure if you intended the listener to be running on every component. Not sure if thats performant.

I definitely want to integrate swipe in a lot of areas. I think they should even have an if touch so we can handle the components a bit differently. A table is a great example. And so is a list that has options. Canvas as well.

tushar-singh commented 8 years ago

Definitely wouldn't wanna add listeners to elements that don't want to use them :)

"if touch" meaning something like Modernizr.touch? We can integrate that probably.