Giter Club home page Giter Club logo

cato.js's Introduction

Build Status codecov

About

Compare Apples To Oranges

Cato Logo

cato.js is a dependency free library for (image) comparison sliders.

It currently gets rewritten in modern JavaScript. Version 1.0.0 (WIP) aims to bring more flexibility, less boilerplate html and better browser support. You can find more info in the roadmap issue.

For the initial (Webkit only) release see v0.0.1

How To

With a CDN

Place the stylesheet inside the <head></head> tag of your HTML file.

  <link rel="stylesheet" src="https://cdn.jsdelivr.net/npm/@herrfugbaum/cato@latest/dest/cato.min.css">

Place the script just before your closing </body> tag of your HTML file.

  <script src="https://cdn.jsdelivr.net/npm/@herrfugbaum/cato@latest/dest/cato.min.js"></script>

Add the simple HTML inside your <body></body> tag of your HTML file.

<div id="my-slider">
  <img src="path/to/my/image" /> <!-- left image -->
  <img src="path/to/my/image" /> <!-- right image -->
</div>

Add this JavaScript snippet inside your <body></body> tags of your HTML file and wrap it with a <script></script> tag. Alternatively you can place this inside a, for example, index.js file and load it with <script src="path/to/my/index.js"></script>. In both cases make sure to place this script tag after the tag in which you load the Cato library from the CDN.

You can find a working example in the examples/global-variable/ directory.

const options = {
  direction: 'vertical', // string horizontal & vertical
  width: 700, // integer defaults to max-width: 100%; via CSS
  height: 450, // integer defaults to height: auto; via CSS
  initial: 30, // integer default = 30px (initial position for slider in px)
  filter: {
    active: true, // boolean
    effect:
      'grayscale(200%)' /* url, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, sepia */,
  },
}

const container = document.getElementById('my-slider')

const mySlider = new Cato(options, container)

mySlider.createSlider()

If you are searching for the initial Webkit-only release, you can find the How To of version 0.0.1 here.

Changelog

0.0.1 Initial Release

cato.js's People

Contributors

herrfugbaum avatar leolabs avatar rastitkac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cato.js's Issues

Keyboard controls are inverted on vertical sliders

Describe the bug
The keyboard controls are inverted on vertical sliders due to the rotate(90deg) style attribute.
If you change it to -90deg the indicator works as expected but now the slider flips its direction.

To Reproduce
Steps to reproduce the behavior:

  1. Focus the range input
  2. Use the arrow keys to navigate the slider
  3. See error

Expected behavior
The slider needs appropriate keyboard support. Pressing the up arrow key โ†‘ should move the slider and it's indicator up, the down arrow key โ†“ should do the opposite.

Why not use div wrappers?

feature request

If we could use div wrappers around the images we could include sub-elements
like text etc and this would be perfect... ;}

Version 1.0.0

Todo

  • Setup the build pipeline for JS
  • Setup the build pipeline for CSS
  • Add support for major browsers
  • Rewrite in modern JavaScript
  • Modularize the code into testable units
  • Get rid of the old HTML structure
  • Make cato responsive
  • Write new manual
  • Add code of conduct
  • Add contributing guidelines

ES6 Example doesn't work

Describe the bug
The example for the ES6 import does not work.

To Reproduce
Steps to reproduce the behavior:

  1. yarn global add serve (ES6 Modules require CORS to be set)
  2. cd into the cato root directory (not into /examples)
  3. in your terminal type serve
  4. Go to http://localhost:5000/examples/es6-module/demo
  5. See error in dev tools

Desktop (please complete the following information):

  • webpack: ^4.24.0
  • Browser: Chrome Version 70.0.3538.102

Additional context

webpack/webpack#3929

webpack/webpack#8318

Center the range indicator

Is your feature request related to a problem? Please describe.
The range indicator is placed to the right or under the slider, giving it a quiet laborious look.

Describe the solution you'd like
The range indicator should be centered, according to the direction of the slider.

Describe alternatives you've considered
None.

Additional context
None.

Does not work on Safari

Describe the bug
We had an issue on Safari 13.0.5 on macOS 10.14.6 caused by clipPath not being prefixed.

To Reproduce

  1. Use as instructed.
  2. Every browser that knows clip-path works as expected
  3. Open the page on Safari
  4. Sliders are visible and operable, but the image doesn't get clip-path style property

Expected behavior
Safari doesn't know clip-path.
It needs to be vendor prefixed by -webkit.

Desktop (please complete the following information):

  • OS: macOS 10.14.6
  • Browser Safari
  • Version 13.0.5

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.