No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to use touch directive along multiple elements?

    Help
    2
    4
    148
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dhax last edited by

      Hi everyone,

      I have a simple 4x4 board game and am trying to figure out how to select multiple adjacent fields with a touch-and-swipe like motion. I checked the different touch directives available but can’t figure out how to do this, and even with the available position, offset, distance and delta information available this seems unnecessary complicated if feasible at all. This is my current code:

      <q-card class="non-selectable">
          <q-card-section class="q-pa-md">
            <div
              v-for="i in 4"
              :key="i"
              class="row justify-center"
            >
              <div
                v-for="j in 4"
                :key="i.toString() + j.toString()"
                v-touch-pan="setMove"  // also how to setMove(i, j) here?
              >
              </div>
            </div>
          </q-card-section>
      </q-card
      

      I guess I am looking for an equivalent to @mouseover but for touch events which allows me to call the setMove function while moving around adjacent fields. I would like the touch event to stop when leaving one field and start again when touching an adjacent field, so that I can call the setMove action with i and j as parameters.

      Any ideas or tips how to achieve something like this?

      Thanks a lot and have a nice day!

      1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman last edited by metalsadman

        Would be helpful if you provide a codepen. As for your handler you can use an arrow function to pass other params ie. v-touch-pan="evt => { setMove(evt, i, j) }". I guess you should check the examples in the docs, im guessing you need some modifiers also stopping other events like what you stated above. Gl

        1 Reply Last reply Reply Quote 0
        • D
          dhax last edited by

          Thanks for having a look. Here’s the codepen with the minimum functionality, so far only the first field gets selected. I tried to wrap the ‘inner’ selectable field with an outer field containing @touchstart.stop in hope it would trigger when going from one field to another one but doesn’t work the way I tried.

          https://codepen.io/dhax/pen/abvxGRq?editors=1111

          1 Reply Last reply Reply Quote 0
          • metalsadman
            metalsadman last edited by

            @dhax Touchpan passes the event, so i think check that object and see which element it has current focus on, once it travels to other div you’ll do some checking if that element has selected class or not then add or remove the said class.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post