Socket
Socket
Sign inDemoInstall

pointer3000

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.5 to 1.0.6

figure.png

2

package.json
{
"name": "pointer3000",
"version": "1.0.5",
"version": "1.0.6",
"description": "✨ A little utility that makes it easy to work with trig values calculated from the pointer's location relative to reference points",

@@ -5,0 +5,0 @@ "main": "pointer3k.js",

@@ -77,3 +77,3 @@ /**

let rad = Math.atan2(y, x);
let deg = rad * (180 / Math.PI);
let deg = (rad * (180 / Math.PI) + 360) % 360;
let dist = Math.hypot(x, y);

@@ -80,0 +80,0 @@

@@ -1,1 +0,1 @@

"use strict";(function(){let t,n,e,o;let i,s,c,d;const p={points:{pointA:{cx:window.innerWidth/2,cy:window.innerHeight/2}}};window.Pointer3k=function(n){if(typeof n==="string"||Number.isInteger(n)){return window.Pointer3k.points[n]}else if(typeof n=="boolean"){d=n}else{n=n||p;t=Object.keys(n.points);e=n.points||{};i=n.console;s=n.initialPos||{pageX:window.innerWidth/2,pageY:window.innerHeight/2};c=n.listener||"mousemove";d=true;if(i){r();l(t)}r(s);window.addEventListener(c,function(t){if(d){r(t)}})}};function r(o){o=o||{};for(let i=0;i<t.length;i++){const s=t[i];let c;let d=e[s].cx=="center"?p.points["pointA"].cx:e[s].cx;let r=e[s].cy=="center"?p.points["pointA"].cy:e[s].cy;let l=(o.pageX||0)-d;let g=(o.pageY||0)-r;let y=Math.atan2(g,l);let f=y*(180/Math.PI);let u=Math.hypot(l,g);c={cx:d,cy:r,x:l,y:g,rad:y,deg:f,dist:u};n=Object.keys(c);e[s]=c;a(c,i)}window.Pointer3k.points=e}function l(t){if(i){const e=document.createElement("div");if(!document.querySelector(".js-pgProps")){e.classList.add("js-pgProps");e.style.position="fixed";e.style.background="rgba(0, 0, 0, 0.7)";e.style.color="white";e.style.fontSize="9px";e.style.fontFamily="Arial";e.style.width=140+"px";e.style.top=0;e.style.right=0;document.body.appendChild(e)}if(document.querySelectorAll(".js-pgPoint").length<t.length){for(var n=0;n<t.length;n++){const o=t[n];const i=Object.keys(window.Pointer3k.points[o]);const s=document.createElement("div");const c=document.createElement("label");s.classList.add("js-pgPoint");c.innerHTML=o;c.style.padding="2px 5px";s.appendChild(c);for(let t=0;t<i.length;t++){const n=document.createElement("div");const e=i[t];n.classList.add("js-pgProp");n.style.padding="2px 5px 2px 15px";n.innerHTML=e+":"+window.Pointer3k.points[e];s.appendChild(n)}e.appendChild(s)}}o=document.querySelectorAll(".js-pgProp")}}function a(t,e){if(o){for(var i=0;i<n.length;i++){const s=e*n.length+i;const c=o[s];const d=n[i];const p=t[d];c.innerHTML=d+":"+p}}}})();
"use strict";(function(){let t,n,e,o;let i,s,c,d;const p={points:{pointA:{cx:window.innerWidth/2,cy:window.innerHeight/2}}};window.Pointer3k=function(n){if(typeof n==="string"||Number.isInteger(n)){return window.Pointer3k.points[n]}else if(typeof n=="boolean"){d=n}else{n=n||p;t=Object.keys(n.points);e=n.points||{};i=n.console;s=n.initialPos||{pageX:window.innerWidth/2,pageY:window.innerHeight/2};c=n.listener||"mousemove";d=true;if(i){r();l(t)}r(s);window.addEventListener(c,function(t){if(d){r(t)}})}};function r(o){o=o||{};for(let i=0;i<t.length;i++){const s=t[i];let c;let d=e[s].cx=="center"?p.points["pointA"].cx:e[s].cx;let r=e[s].cy=="center"?p.points["pointA"].cy:e[s].cy;let l=(o.pageX||0)-d;let g=(o.pageY||0)-r;let y=Math.atan2(g,l);let f=(y*(180/Math.PI)+360)%360;let u=Math.hypot(l,g);c={cx:d,cy:r,x:l,y:g,rad:y,deg:f,dist:u};n=Object.keys(c);e[s]=c;a(c,i)}window.Pointer3k.points=e}function l(t){if(i){const e=document.createElement("div");if(!document.querySelector(".js-pgProps")){e.classList.add("js-pgProps");e.style.position="fixed";e.style.background="rgba(0, 0, 0, 0.7)";e.style.color="white";e.style.fontSize="9px";e.style.fontFamily="Arial";e.style.width=140+"px";e.style.top=0;e.style.right=0;document.body.appendChild(e)}if(document.querySelectorAll(".js-pgPoint").length<t.length){for(var n=0;n<t.length;n++){const o=t[n];const i=Object.keys(window.Pointer3k.points[o]);const s=document.createElement("div");const c=document.createElement("label");s.classList.add("js-pgPoint");c.innerHTML=o;c.style.padding="2px 5px";s.appendChild(c);for(let d=0;d<i.length;d++){const t=document.createElement("div");const n=i[d];t.classList.add("js-pgProp");t.style.padding="2px 5px 2px 15px";t.innerHTML=n+":"+window.Pointer3k.points[n];s.appendChild(t)}e.appendChild(s)}}o=document.querySelectorAll(".js-pgProp")}}function a(t,e){if(o){for(var i=0;i<n.length;i++){const s=e*n.length+i;const c=o[s];const d=n[i];const p=t[d];c.innerHTML=d+":"+p}}}})();

@@ -7,3 +7,3 @@ # Pointer3000

# Why?
I experiment a lot with interactive graphics and interaction in general, and have found that I often have to calculate `this` and `that`, particularly the distance and angle from (a) specific point(s). I decided to make this little utility so I can just plop it in and start trying things out. This is meant to be used in compositions with just regular DOM elements– the constraint of what can be done with just a 'regular' page is a great source of possibility.
I experiment a lot with interactive graphics and interaction in general, and have found that I often have to calculate `this` and `that`, particularly the distance and angle from (a) specific point(s). I decided to make this little utility so I can just plop it in and start trying things out. This is meant to be used in compositions with just regular DOM elements– the constraint of what can be done with just a 'regular' page I find to be a very welcome creative challenge.

@@ -18,3 +18,3 @@ While the output is very 'basic', I found that what can be done with them when used to manipulate `things` are endless. I hope you find this stirring your creativity and imagination. Lots of possibilities!

# How?
Simply call Pointer3000. This will create a global variable `Pointer3k` which contains `points`. Values are updated onMouseMove by default (see available settings below).
Simply call Pointer3000. This will create a global variable `Pointer3k` which contains `points`. Values are updated onMouseMove by default (see available settings below). Download the script or `npm install pointer3000`.

@@ -26,2 +26,4 @@ ```js

While the utility registers events on `mousemove` by default, you can use values via `requestAnimationFrame` so you don't have to register another `mousemove` listener to update the view.
If initialised without arguments it will simply register the center of the viewport as its one and only reference point. The default name of this auto-created point is `pointA`. If you do a `console.log(Pointer3k('pointA')` after initialisation, you will find that a point object contains the following data:

@@ -42,2 +44,4 @@

![fig](https://d3uepj124s5rcx.cloudfront.net/items/1F2y3c371M2E3A2r1x32/figure.png?v=8fb5b2a0)
But you probably want to define specific points of reference, have multiple and even name them for convenience, so you'd want to initialize it like so:

@@ -44,0 +48,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc