All Projects → vin-ni → Hover On Touch

vin-ni / Hover On Touch

Licence: mit
A pure Javascript Plugin for an alternative hover function that works on mobile and desktop devices. It triggers a hover css class on »Taphold« and goes to a possible link on »Tap«. It works with all html elements.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Hover On Touch

Vuetify Swipeout
👆 A swipe out example built with Vue CLI 3 + Vuetify + Swiper.
Stars: ✭ 117 (-54.3%)
Mutual labels:  mobile, touch, touch-events
Swiper
Most modern mobile touch slider with hardware accelerated transitions
Stars: ✭ 29,519 (+11430.86%)
Mutual labels:  mobile, touch, touch-events
Tap
1Kb library for easy unified handling of user interactions such as mouse, touch and pointer events.
Stars: ✭ 541 (+111.33%)
Mutual labels:  tap, touch, touch-events
Keen Slider
The HTML touch slider carousel with the most native feeling
Stars: ✭ 3,097 (+1109.77%)
Mutual labels:  mobile, touch, touch-events
Mars
腾讯移动 Web 前端知识库
Stars: ✭ 9,255 (+3515.23%)
Mutual labels:  mobile, touch
React Easy Swipe
Easy handler for common swipe operations
Stars: ✭ 85 (-66.8%)
Mutual labels:  mobile, touch
Embla Carousel
A lightweight carousel library with fluid motion and great swipe precision.
Stars: ✭ 1,874 (+632.03%)
Mutual labels:  mobile, touch
React Drag Drawer
A responsive mobile drawer that is draggable on mobile, and falls back to a modal on desktop
Stars: ✭ 135 (-47.27%)
Mutual labels:  mobile, touch
Better Gesture
A gesture library use for pc, mobile, vue, and mini programs
Stars: ✭ 419 (+63.67%)
Mutual labels:  mobile, touch
Interact.js
JavaScript drag and drop, resizing and multi-touch gestures with inertia and snapping for modern browsers (and also IE9+)
Stars: ✭ 10,561 (+4025.39%)
Mutual labels:  mobile, touch
Slider
Touch swipe image slider/slideshow/gallery/carousel/banner mobile responsive bootstrap
Stars: ✭ 2,046 (+699.22%)
Mutual labels:  mobile, touch
Any Touch
👋 手势库, 按需2kb~5kb, 兼容PC / 移动端
Stars: ✭ 567 (+121.48%)
Mutual labels:  tap, touch
React Cursor Position
A React component that decorates its children with mouse and touch coordinates relative to itself.
Stars: ✭ 136 (-46.87%)
Mutual labels:  tap, touch
Trip
移动前端开发经验指南
Stars: ✭ 550 (+114.84%)
Mutual labels:  mobile, touch
React Swipeable
React swipe event handler hook
Stars: ✭ 1,348 (+426.56%)
Mutual labels:  mobile, touch
React Fastclick
Fast Touch Events for React
Stars: ✭ 476 (+85.94%)
Mutual labels:  mobile, touch
Framework7
Full featured HTML framework for building iOS & Android apps
Stars: ✭ 16,560 (+6368.75%)
Mutual labels:  mobile, touch
Vue Gallery
📷 Responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers.
Stars: ✭ 405 (+58.2%)
Mutual labels:  mobile, touch
gestures
A library for normalized events and gesture for desktop and mobile.
Stars: ✭ 31 (-87.89%)
Mutual labels:  tap, touch
react-fastclick
A react component that triggers click events for taps (short localized touches)
Stars: ✭ 20 (-92.19%)
Mutual labels:  tap, touch

Hover on Touch 3.0

This is a pure Javascript Plugin for an alternative hover function that works on mobile and desktop devices. It triggers a hover css class on »Taphold« and goes to a possible link on »Tap«. It works with all html elements.

Here's a demo for touch devices a shop demo and here's a demo video for desktops.

Preview of the Plugin on a Portfolio Preview with nice colors and animation Preview of the Plugin for a shop Preview of the Plugin for a text with an ad behind

Installing

<script src="your/path/hoverontouch.js"></script>

and add the following to your html:

<script type="text/javascript">
    var HoverOnTouch = new HoverOnTouch();
</script>

Description

When you touch an element, the »hoverontouch--aktiv« class is applied and triggers the effect defined in your css. For example it can hide an element and show some secondary information, initiate a link hover or just trigger any kind of css animation. If you release under 250ms, the touch event is interpreted as a click and a redirection to the given link is triggered (if there is one provided). Otherwise, if you hold longer, the event is interpreted as a »Taphold« and the old status is shown again on release.

This brings additional possibilities for the user to interact with the content of a website. For example, the user can read secondary information while scrolling a page. It further makes it feel more "alive" and "applike".

Some thoughts on what the plugin can be used for can be found on my blog entry.

HTML Structure

Each wrapper of your element you want to use it on, needs the class ».hoverontouch« Add as many objects as you like.

<a href="www.example.com" class="hoverontouch">
    <div class="cover"><img src="img/path"></div>
</a>

//or

<a href="www.example.com" class="hoverontouch">
    <div class="testObject">
        <div class="info"><img src="img/path"></div>
        <div class="cover"><img src="img/pth2"></div>
    </div>
</a>


Css

In the CSS you need to rename your hover functions this way:

.cover:hover

to

.hoverontouch--aktiv .cover

»Example:«

.object {
    width: 100vw;
    height: 250px;
    margin-bottom: 25px;
    display: block;
}

.cover {
    position: absolute;
    width: inherit;
    height: inherit;
    background-color: blue;
}

.hoverontouch--aktiv .cover {
    opacity: 0;
}

.info {
    position: absolute;
    width: inherit;
    height: inherit;
    background-color: green;
}

Result

On Tap Hold and Hover, the .cover div gets an opacity 0. On click or tap, the link is triggered.

UX

These are some points I think are necessary to make this approach work ux wise:

  • all clickable elements should have a second layer or an animation (to be consistent)
  • the elements should take reasonable space on the screen, so the user touches them automatically while scrolling (Otherwise this feature would need to be explained)
  • if there is relevant secondary information, it should leave space for the thumb

Link to my blogpost with additional thoughts.

Features & Functions

// Destroy the plugin and remove all event listeners:
hoverontouch.destroy();

// ReInit the plugin to parse new Links if they are added dynamically or new content is pushed to the page (for example pagination)
hoverontouch.reInitHoverOnTouch();
  • Put any html elements together
  • Works while scrolling, so users can see details while scrolling through the page
  • Gifs restart on display
  • For looping animations save the gifs as »looping«, for normal animations save them as »playing once«
  • The script works on mobile, on desktop and devices that support mouse and touch events.

Contribution

If anyone wants to contribute, just fork the project or write me at [email protected] :)

Created by Vinzenz Aubry & Emmanuel Durgoni

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].