@standard-library/galvo-dom-clicker

0.3.0 • Public • Published

galvo-dom-clicker

A function that, given a class name, creates an element with a corresponding click event stream. Could be used for adding left and right arrows to a slideshow.

Installation

yarn add @standard-library/galvo-dom-clicker

Usage

import clicker from "@standard-library/galvo-dom-clicker";

button = clicker("button");

button.element
// => <div class="button"></div>
button.click
// => Kefir.Stream
button.mousedown
// => Kefir.Stream
button.mouseup
// => Kefir.Stream

Using galvo this event stream can be used to move forward and backward in a sequence of elements:

import galvo from "@standard-library/galvo";
import clicker from "@standard-library/galvo-dom-clicker";

const next = clicker("paginator");
const sequence = galvo({
  advance: next.click
}, ["a", "b", "c"]);

next.element.click();
next.element.click();

sequence.current
// => a---b---c

/@standard-library/galvo-dom-clicker/

    Package Sidebar

    Install

    npm i @standard-library/galvo-dom-clicker

    Weekly Downloads

    5

    Version

    0.3.0

    License

    MIT

    Unpacked Size

    351 kB

    Total Files

    10

    Last publish

    Collaborators

    • standard-library