3.2.0 • Published 1 year ago

cocoen v3.2.0

Weekly downloads
1,750
License
MIT
Repository
github
Last release
1 year ago

Cocoen

Version Downloads Last commit Build Status Coverage Status License

Touch-enabled before/after slider. Inspired by before-after.js.

Example

Quick start

Demo

Install

Install with NPM

npm install cocoen --save

Get it from CDN

<!DOCTYPE html>
<html>
  <head>
    <title>Cocoen from CDN</title>
  </head>
  <body>
    <div class="cocoen">
      <img src="img/before.jpg" alt="" />
      <img src="img/after.jpg" alt="" />
    </div>

    <!-- Load Cocoen library -->
    <script src="https://unpkg.com/cocoen/dist/cocoen.js"></script>

    <!-- Turns all `.cocoen` elements into Cocoens -->
    <script>
      Cocoen.parse(document.body);
    </script>
  </body>
</html>

Or download the latest release.

Usage

Only the class cocoen is mandatory to apply proper default styles:

<div class="cocoen">
  <img src="img/before.jpg" alt="" />
  <img src="img/after.jpg" alt="" />
</div>

Include the cocoen.js script in your page, and then:

Cocoen.create(document.querySelector('.cocoen'));

Multiple Cocoens in one page:

Cocoen.parse(document.body);

Options

OptionTypeDescription
startStringDefault: "50". The start position of Cocoen as a percentage.
colorStringDefault: "#fff". Color of drag control

Events

OptionDescription
cocoen-component:connectedFires when Cocoen mounts
cocoen-component:disconnectedFires when Cocoen unmounts
cocoen-component:resizedFires when Cocoen dimensions are updated
cocoen-component:updatedFires when Cocoen is updated
cocoen-component:visibleFires when Cocoen is in viewport

License

The code and the documentation are released under the MIT License.

3.1.3

1 year ago

3.1.2

1 year ago

3.2.0

1 year ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.5

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.0

8 years ago