Giter Site home page Giter Site logo

dr-eti / shwypehammer_shinyswipr_revisited Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 136 KB

App demonstrating a modified version of shinyswipr - an R package for building a card swipe carousel UI. Fixes an issue occurring on devices that allow both click and touch events.

License: GNU General Public License v3.0

R 31.95% CSS 13.16% JavaScript 54.88%
swipe swipegesture shiny tinder-swiper tinder carousel hammerjs cards r javascript css shinysense interactive

shwypehammer_shinyswipr_revisited's Introduction

ShwypeHammer: shinyswipr revisited

Motivation

shinyswipr is an R package that enables users to build a 'swipe-able' card-deck interface in Shiny (https://github.com/nstrayer/shinyswipr). Yet I've soon noticed that a Shiny app built using the original shinyswipr package won't work on devices that enable both touch and mouse input simultaneously (e.g. a touchscreen laptop).

What's the contribution?

After opening an issue on shinyswipr's github - without much follow-up - I have taken the liberty to have a stab at the issue myself.

Specifically, I've realised that shinyswipr relies on TocuhSwipe.js for gesture detection. I think that Hammer.js does a better job in the presence of 'hybrid' devices, and therefore I wanted to change the piping to do the switch. I didn't rewrite the package - I'm not that clever. But I propose here a modified version of the "quote swipr" example described in https://livefreeordichotomize.com/2017/03/12/introducing-shinyswipr-swipe-your-way-to-a-great-shiny-ui/

On the surface, the modified app:

  • Displays a pair of randomly generated quotes and images on a card deck
  • Uses a "multi page" layout so that the swipe log is displayed on a separate tab rather than under the card deck

Under the hood I changed the inner workings of shinyswipr as follows

  • Self contained app, reading .js and .css from its own \www subfolder instead of relying on the shinywsipr package location
  • Hammer.js replaces touchSwipe.js as a touch detection device
  • own .js and .css files governing a different card swipe animation based on hammer.js (replace shinySwiper.js and swiprStyle.css)

Caveat

In wrapping my head around shinyswipr's inner workings I've become aware of the following changes in 'best practices' since the package was first released:

However, after fiddling a bit with these updates - without much success - I've decided to stick with the "old" approach: after all, the main motivation was to get the bloody thing to recognise a swipe on a hybrid device - wasn't it? But conscious there is room for a neater code if the latest best practice is taken into account.

What does it do?

Below I show few screenshots taken from running the app locally. The web browser (Firefox) is in web developer mode to show the custom logs.

First, we start with the app in 'rest' state. The user is presented with a card containing a random quote from the fortunes R package, and a random image taken from the web. the logs displays a successful connection from R Shiny to the custom JavaScript via a dedicated module server

image

Next, the user drags the card right, but without releasing it. A pan movement is detected via Hammer.js and displayed in the console log.

image

Let's assume the user is hesitant and doesn't quite swipe yet. Whilst a pan end movement is detected, the card snaps back in place. Whether a gesture qualifies as a swipe depends on some checks about the velocity and span of the movement. The console log shows "NOSWIPE" instead of a swipe direction. The logical "true" is associated with a state variable denoting whether the current card is to be kept in the deck or not.

image

Now let's assume the user swipes right with sufficient intent. The top card has changed with a new random quote and image. The console log displays the swipe direction and the "keep" state variable takes the value "false". The card has been swiped indeed.

image

A look a the "swipe log" tab shows that we now have a row recording the quote and swipe direction associated with the card the user has just swiped.

image

shwypehammer_shinyswipr_revisited's People

Contributors

dr-eti avatar

Watchers

 avatar  avatar

shwypehammer_shinyswipr_revisited's Issues

Ability to re-start progress

We have the swipe log on google sheets, which serves as a history and gives the last edge ID (card ID)
... but can the user pick it up form there?

Skip cards based on transitivie property

This is a massive User Experience problem.
For the user, it is a cognitive burden to evaluate ALL possible edges. However we should be able to skip some

Example: swipes up and down should help SKIP some cards (edges); also we can get extra skips using transitivity (if A influences B, and B influences C, there is no need to evaluate whether A influences C)

Capture time spent by user

Timing in this kind of paired comparisons is academically relevant and never captured.

Useful time-related features could include

  • at each session, capture user time on app (from log in to log out);
  • for each card, capture time to swipe (time elapsed from when the card is displayed to when the user makes a swipe

Scoring device

At the moment the app detects the direction of swipe. When the user swipes right we need to enable an UI to record a score on an ordinal scale (e.g. radial button?);
This seems an issue linked to "Dynamic UI" in shiny...

Skip cards when swiping up and down

This is a massive User Experience problem.
For the user, it is a cognitive burden to evaluate ALL possible edges. However we should be able to skip some

DONE: Swipe up and down (influence both ways/no influence either way)

Enable multiple simultanous users

Much like in Xiang's original swipe card UI - it would be good to know if we can deploy the app simultaneously across multiple users;
...this might require knowledge of Shiny widgets that could be useful for the purpose of logging in user details once the app is deployed

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.