Skip to content

biancojs/pointer

Repository files navigation

bianco.pointer

Build Status NPM version NPM downloads MIT License

Usage

import pointer from 'bianco.pointer'

// get the x and y position from any Mouse or Touch event
const { x, y } = pointer.position(touchEvent)

API

Table of Contents

position

Normalize the pointer events to get a single position of the pointer on the screen

Parameters

Examples

import { position } from 'bianco.pointer'
import { add } from 'bianco.events'


add(window, 'touchmove mousemove', function(event) {
  const { x, y } = position(event)

  console.log('Your pointer y is=', y, 'your pointer x is', x)
})

Returns Object position - pointer position on the screen

Returns number position.x - x condinates relative to the screen

Returns number position.y - y condinates relative to the screen