Giter Site home page Giter Site logo

Event Bubbling about touchy HOT 4 CLOSED

hotstudio avatar hotstudio commented on July 21, 2024
Event Bubbling

from touchy.

Comments (4)

dapinitial avatar dapinitial commented on July 21, 2024

This is an issue with the wheel, because while it rotates the circle is really a square because of the box model and I am finding that only SVG can really mask the shape properly and not leave any hit area. Still haven't resolved the event bubble, sort of took a step back from it.

from touchy.

dapinitial avatar dapinitial commented on July 21, 2024

http://jsfiddle.net/ymtV3/

from touchy.

dapinitial avatar dapinitial commented on July 21, 2024

If anyone has a similar issue what I've done is if it's spinning, hidden the items, and I am applying a background to the wheel container that shows during it so it's a faux way of doing things. I have several layers inside the wheel so whenever an option is clicked or selected and you go into another screen it applies a particular class to change the background... This is a suitable solution for now... but I guess I would still like to figure this plugin out. I do like Touchy. Now onto the SVG foreignObject piece.

from touchy.

fisherwebdev avatar fisherwebdev commented on July 21, 2024

Hi, you're not the first person to struggle with Touchy's event delegation issues.

The idea behind Touchy is that all events are actually registering listeners on the document, so when you say:

$('#wheel').bind('touchy-rotate', handleTouchyRotate);

Contrary to how it looks and normally operates, this bind() is actually setting up a listener on the document. When the event (for example, "touchmove") bubbles up to the document, a proxy event handler fires a custom event on the element you called bind() on.

But while this is great for working with a global environment where you might need to tell the difference between a swipe and a drag, it messes with our normal use of event delegation and bubbling.

Sometimes, this can be dealt with by adding additional calls to bind() for all the elements in the tree that you are concerned with. But this does not work in the case of Touchy's rotate event. Your example is making me wonder if it wouldn't be better to be able to declare what the ultimate target of the event should be, and then all child elements would bubble their events until that target is reached... I have some experiments in the other branches of the code, but I have yet to figure out the best solution.

Please see the other discussions on the issue tracker and other branches to see where this has gone so far.

#4
#5
https://github.com/HotStudio/touchy/tree/event-target

from touchy.

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.