Giter VIP home page Giter VIP logo

split-view's Introduction

Split View

Split View is a web component for comparing two images. To use it include /dist/split-view.js in a page and then use <split-view>[...]</split-view> to use the component. It's best used with <picture> elements.

Split view

Goals

The aim of <split-view> is provide an accessible image comparison component. Under the hood <split-view> uses an HTML range input to control the position of the slider rather than a JavaScript powered div element which is more commonly used for this sort of input element. Using an HTML input means all of the accessibility features of the browser are still usable.

Usage

Give the two elements to be compared attributes of slot="top" and slot="bottom".

<split-view>
  <picture slot="top">
    <img src="https://source.unsplash.com/600x400/?day" alt="Day" />
  </picture>
  <picture slot="bottom">
    <img src="https://source.unsplash.com/600x400/?night" alt="Night" />
  </picture>
</split-view>

Split View also supports an optional mode and start parameters. mode determines how the top and bottom layers are blended. start defines the start point for the comparison line (in percent).

<split-view mode="screen" start=25>
  <picture slot="top">
    <img src="https://source.unsplash.com/600x400/?day" alt="Day" />
  </picture>
  <picture slot="bottom">
    <img src="https://source.unsplash.com/600x400/?night" alt="Night" />
  </picture>
</split-view>

Options are the same as CSS's mix-blend-mode.

Accessibility

Accessibility labels

<split-view> accepts two labels that are used for accessibilty;

  • split-view-label - An aria-label value for the component
  • slider-label - A label used to describe the slider

Focus outline

By default split-view will have a focus outline if the user has focused on it. This is desirable and good practice for making accessible websites, but if you really have to switch it off you can by defining a style in your page of;

split-view {
  --outline: none;
}

split-view's People

Contributors

onion2k avatar

Stargazers

 avatar Marty Helmick avatar Pascal Tbf avatar 板蓝根 avatar Bryan Ollendyke avatar  avatar KeiSei avatar  avatar Eric Chung avatar Whoami avatar Mateusz Świder avatar

Watchers

 avatar James Cloos avatar

Forkers

tawawhite

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.