All Projects → NigelOToole → Direction Reveal

NigelOToole / Direction Reveal

Licence: mit
Direction aware content reveals via hover or tab on an element.

Programming Languages

javascript
184084 projects - #8 most used programming language
es6
455 projects

Projects that are alternatives of or similar to Direction Reveal

Hugo Swift Theme
A simple open source theme for publishing with hugo
Stars: ✭ 85 (-82.97%)
Mutual labels:  gallery, sass
Nanogallery2
a modern photo / video gallery and lightbox [JS library]
Stars: ✭ 488 (-2.2%)
Mutual labels:  gallery
Gridder
A jQuery plugin that displays a thumbnail grid expanding preview similar to the effect seen on Google Images.
Stars: ✭ 449 (-10.02%)
Mutual labels:  gallery
Gulp Ruby Sass
Compile Sass to CSS with Ruby Sass
Stars: ✭ 476 (-4.61%)
Mutual labels:  sass
Progress Tracker
A HTML component to illustrate the steps in a multi step process e.g. a multi step form, a timeline or a quiz.
Stars: ✭ 461 (-7.62%)
Mutual labels:  sass
Scrollgalleryview
🌉 Android image gallery with bottom scroll view
Stars: ✭ 481 (-3.61%)
Mutual labels:  gallery
Youtube To Mp3
⚡️Electron application to convert and download YouTube videos as MP3s
Stars: ✭ 430 (-13.83%)
Mutual labels:  sass
Angular Electron
Ultra-fast bootstrapping with Angular and Electron (Typescript + SASS + Hot Reload) 🚤
Stars: ✭ 4,914 (+884.77%)
Mutual labels:  sass
Vscode Live Sass Compiler
Compile Sass or Scss file to CSS at realtime with live browser reload feature.
Stars: ✭ 488 (-2.2%)
Mutual labels:  sass
Vanilla Framework
From community websites to web applications, this CSS framework will help you achieve a consistent look and feel.
Stars: ✭ 476 (-4.61%)
Mutual labels:  sass
Csshake
CSS classes to move your DOM!
Stars: ✭ 4,531 (+808.02%)
Mutual labels:  sass
Neumorphism Ui Bootstrap
Neumorphism inspired UI Kit: web components, sections and pages in neumorphic style built with Bootstrap CSS Framework
Stars: ✭ 463 (-7.21%)
Mutual labels:  sass
Libsass Python
A straightforward binding of libsass for Python. Compile Sass/SCSS in Python with no Ruby stack at all!
Stars: ✭ 484 (-3.01%)
Mutual labels:  sass
Pickphotosample
Photo Picker Of Android Library
Stars: ✭ 457 (-8.42%)
Mutual labels:  gallery
A11y Style Guide
Accessibility (A11Y) Style Guide
Stars: ✭ 493 (-1.2%)
Mutual labels:  sass
Skplayer
🎵 A simple & beautiful HTML5 music player
Stars: ✭ 437 (-12.42%)
Mutual labels:  sass
Laravel Vue Boilerplate
🐘 A Laravel 6 SPA boilerplate with a users CRUD using Vue.js 2.6, GraphQL, Bootstrap 4, TypeScript, Sass, and Pug.
Stars: ✭ 472 (-5.41%)
Mutual labels:  sass
Utility Opentype
Simple, CSS utility classes for advanced typographic features.
Stars: ✭ 481 (-3.61%)
Mutual labels:  sass
Neat
Neat is maintained by the thoughtbot design team. It is funded by thoughtbot, inc. and the names and logos for thoughtbot are trademarks of thoughtbot, inc.
Stars: ✭ 4,506 (+803.01%)
Mutual labels:  sass
Thumbsup
Generate static HTML photo / video galleries
Stars: ✭ 493 (-1.2%)
Mutual labels:  gallery

Direction Reveal

A plugin that detects the direction a user enters or leaves an element allowing you to reveal or hide content based on this direction.

View demo

Installation

$ npm install direction-reveal --save-dev

Usage

Import JS

The script is an ES6(ES2015) module but the compiled version is included in the build as "src/scripts/direction-reveal-umd.js". You can also copy "src/scripts/direction-reveal.js" into your own site if your build process can accommodate ES6 modules.

import DirectionReveal from 'direction-reveal';

// Init with default setup
const directionRevealDemo = DirectionReveal();

// Init with all options at default setting
const directionRevealDefault = DirectionReveal({
  selector: '.direction-reveal',
  itemSelector: '.direction-reveal__card',
  animationName: 'swing',
  animationPostfixEnter: 'enter',
  animationPostfixLeave: 'leave',
  enableTouch: true,
  touchThreshold: 250
});

Options

Property Default Type Description
selector '.direction-reveal' String Container element selector.
itemSelector '.direction-reveal__card' String Item element selector.
animationName 'swing' String Animation class.
animationPostfixEnter 'enter' String Animation CSS class postfix for enter event.
animationPostfixLeave 'leave' String Animation CSS class postfix for leave event.
enableTouch true Boolean Adds touch event to show content on first click then follow link on the second click.
touchThreshold 250 Number(ms) The touch length in ms to trigger the reveal, this is to prevent triggering if user is scrolling.

Import SASS

@import "node_modules/direction-reveal/src/styles/direction-reveal.scss";

Markup

<div class="direction-reveal">

  <a href="#" class="direction-reveal__card">
    <img src="images/image.jpg" alt="Image" class="img-fluid">

    <div class="direction-reveal__overlay direction-reveal__anim--enter">
      <h3 class="direction-reveal__title">Title</h3>
      <p class="direction-reveal__text">Description text.</p>
    </div>
  </a>

  ...
</div>

Using other tags

The demos use <a> tags for the "direction-reveal__card" but a <div> can be used as below, specifying the tabindex ensures keyboard navigation works as expected. They can all have a value of 0 and will follow the source order of the divs.

<div class="direction-reveal__card" tabindex="0">
  ...
</div>

Inverted animations

Most of the animations above can be inverted so the overlay is visible by default and animates out on hover. Change the class 'direction-reveal__anim--enter' to 'direction-reveal__anim--leave' for this effect.

You can also add the class 'direction-reveal__anim--enter' or 'direction-reveal__anim--leave' to the image to animate it at the same time as overlay. This effect can be seen in the Slide & Push demo.

Events

A 'directionChange' event is broadcast once a user enters/leaves an item with information about the action(enter,leave) and direction(top, right, bottom, left).

document.querySelector('#test').addEventListener('directionChange', (event) => { 
  console.log(`Action: ${event.detail.action} Direction: ${event.detail.direction}`);
});

Compatibility

Touch support

The plugin will detect touch support and reveal the hidden content on first click then follow link on the second click. This can be disabled with the option enableTouch.

Browser support

Supports all modern browsers(Firefox, Chrome and Edge) released as of January 2018. For older browsers you may need to include polyfills for Nodelist.forEach, Element.classList and Passive Event Listeners.

Demo site

Clone or download from Github.

$ npm install
$ gulp serve

Credits

Inspired by a Codepen by Noel Delgado, this Stack overflow answer, the article Get an Element's position using javascript and Images from Unsplash..

License

MIT © Nigel O Toole

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].