Socket
Book a DemoInstallSign in
Socket

pointer-cursor

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pointer-cursor

synthesized mouse cursor

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

pointer-cursor

for when you've got a fullscreen game, but you want a cursor.

var interact = require('interact')
  , cursor = require('./index')
  , element

var pointer = interact(document.body)
  , current

pointer.on('attain', function(movements) {
  var to = current = cursor(element, true)
  element = to.element
  movements.pipe(to)
})

document.body.onclick = function(ev) {
  if(current) {
    current.click(ev.button)
  }
}

api

cursor([element][, constrainToWindow][, dispatchHover]) -> writable stream

creates a cursor element if none is given, and returns it as a writable stream suitable for piping interact movement streams into.

if constrainToWindow isn't given, it defaults to true; the cursor will not be able to leave the window.

if dispatchHover isn't given, it defaults to false; enabling it will dispatch mouseover and mouseout events to the elements hovered. note that this is experimental and slow.

stream.click([button=0])

dispatch a click event to the currently hovered element.

stream.element

the element representing the cursor.

stream.target() -> element or null

the element currently hovered.

stream.constrain(shouldConstrain=true) -> Boolean

set whether or not to constrain mouse movements. if setting to true, will recalculate window size and re-constrain the existing cursor.

license

MIT

Keywords

pointer-lock

FAQs

Package last updated on 12 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts