Giter VIP home page Giter VIP logo

dom-reduce's Introduction

dom-reduce

Build Status

Small library for dealing with browser DOM events in a reducible style. This lets operate on user events as with regular collection data structures in composable manner.

Usage

var open = require("dom-reduce/event")
var map = require("reducers/map")
var filter = require("reducers/filter")
var fold = require("reducers/fold")
var takeWhile = require("reducers/take-while")

// Take stream of mouse move events.
var moves = open(document.documentElement, "mousemove")
// Map it to the axis positions
var axis = map(moves, function(event) {
  return { x: event.clientX, y: event.clientY }
})
// Filter down to the area we're interested in.
var lineAxis = filter(axis, function(value) {
  return value.x > 190 && value.x < 200
})

// Take positions only until mouse reaches the edge.
// Note that when this contidion is met event listeners
// will automatically be removed.
var values = takeWhile(lineAxis, function(value) {
  return value.y > 0
})

// Drow sowething in the given range.
fold(lineAxis, function(position) {
  draw(position)
})

Install

npm install dom-reduce

Develop

Library is developed using awesome browserify! Phantomify is used for running test in a PhantomJS.

dom-reduce's People

Contributors

gozala avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

raynos

dom-reduce's Issues

drop attachEvent / detachEvent

The IE event model is a joke. It's not even worth using.

If you want IE<9 support your better off building your own event model.

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.