New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

focalbox

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

focalbox - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

7

CHANGELOG.md

@@ -0,4 +1,9 @@

# 0.0.3
- add `isFocused` function
# 0.0.2
- add focus mode
- add focus mode

@@ -44,2 +44,5 @@ // Generated by LiveScript 1.6.0

},
isFocused: function(){
return this.box.classList.contains('focus');
},
focus: function(v){

@@ -46,0 +49,0 @@ v == null && (v = true);

2

dist/focalbox.min.js

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

(function(){var hub,main,renderinfo;hub={focus:function(v){v==null&&(v=true);return this.mask.classList.toggle("active",v)},init:function(){if(this.root){return}document.body.appendChild(hub.root=document.createElement("div"));hub.root.appendChild(hub.mask=document.createElement("div"));hub.root.classList.add("focalbox-host");return hub.mask.classList.add("focalbox-mask")}};main=function(opt){opt==null&&(opt={});this.opt=opt;this.box=null;this.target=null;this.hosts=[];this.addHost(opt.host);this.selector=opt.selector||null;this.padding=opt.padding||6;this["class"]=Array.isArray(opt["class"])?opt["class"]:typeof opt["class"]==="string"?opt["class"].split(" "):[];this.init();return this};main.prototype=import$(Object.create(Object.prototype),{init:function(){hub.init();hub.root.appendChild(this.box=document.createElement("div"));this.box.classList.add("focalbox");this.box.classList.add.apply(this.box.classList,this["class"]);return renderinfo.add(this)},focus:function(v){v==null&&(v=true);this.box.classList.toggle("focus",v);return hub.focus(v)},addHost:function(h){return this.hosts=this.hosts.concat((Array.isArray(h)?h:[h]).map(function(it){if(typeof it==="string"){return document.querySelector(it)}else if(it){return it}else{return null}}).filter(function(it){return it}))},removeHost:function(h){h=Array.isArray(h)?h:[h];return this.host=this.host.filter(function(it){return~h.indexOf(it)})},setTarget:function(n){if(n&&this.selector){if(!(n.matches&&n.matches(this.selector))){return}}if(!this.hosts.filter(function(it){return it.contains(n)}).length){n=null}this.target=n;return this.render()},render:function(){var n,ref$,box,p,x,y;n=this.target;if(!n){return this.box.classList.remove("active","moving")}ref$=[n.getBoundingClientRect(),this.padding],box=ref$[0],p=ref$[1];x=box.x-p+window.scrollX;y=box.y-p+window.scrollY;import$(this.box.style,{left:x+"px",top:y+"px",width:box.width+p*2+"px",height:box.height+p*2+"px"});if(this.box.classList.contains("active")){this.box.classList.add("moving")}return this.box.classList.add("active")}});renderinfo={list:[],running:false,render:function(){return this.list.map(function(it){return it.render()})},tick:function(){var this$=this;if(!renderinfo.running){return}return setTimeout(function(){return requestAnimationFrame(function(){return this$.render()})},500)},add:function(it){this.list.push(it);if(this.running){return}this.running=true;return this.render()}};window.addEventListener("scroll",function(){return renderinfo.render()});if(typeof module!="undefined"&&module!==null){module.exports=main}if(typeof window!="undefined"&&window!==null){window.focalbox=main}function import$(obj,src){var own={}.hasOwnProperty;for(var key in src)if(own.call(src,key))obj[key]=src[key];return obj}}).call(this);
(function(){var hub,main,renderinfo;hub={focus:function(v){v==null&&(v=true);return this.mask.classList.toggle("active",v)},init:function(){if(this.root){return}document.body.appendChild(hub.root=document.createElement("div"));hub.root.appendChild(hub.mask=document.createElement("div"));hub.root.classList.add("focalbox-host");return hub.mask.classList.add("focalbox-mask")}};main=function(opt){opt==null&&(opt={});this.opt=opt;this.box=null;this.target=null;this.hosts=[];this.addHost(opt.host);this.selector=opt.selector||null;this.padding=opt.padding||6;this["class"]=Array.isArray(opt["class"])?opt["class"]:typeof opt["class"]==="string"?opt["class"].split(" "):[];this.init();return this};main.prototype=import$(Object.create(Object.prototype),{init:function(){hub.init();hub.root.appendChild(this.box=document.createElement("div"));this.box.classList.add("focalbox");this.box.classList.add.apply(this.box.classList,this["class"]);return renderinfo.add(this)},isFocused:function(){return this.box.classList.contains("focus")},focus:function(v){v==null&&(v=true);this.box.classList.toggle("focus",v);return hub.focus(v)},addHost:function(h){return this.hosts=this.hosts.concat((Array.isArray(h)?h:[h]).map(function(it){if(typeof it==="string"){return document.querySelector(it)}else if(it){return it}else{return null}}).filter(function(it){return it}))},removeHost:function(h){h=Array.isArray(h)?h:[h];return this.host=this.host.filter(function(it){return~h.indexOf(it)})},setTarget:function(n){if(n&&this.selector){if(!(n.matches&&n.matches(this.selector))){return}}if(!this.hosts.filter(function(it){return it.contains(n)}).length){n=null}this.target=n;return this.render()},render:function(){var n,ref$,box,p,x,y;n=this.target;if(!n){return this.box.classList.remove("active","moving")}ref$=[n.getBoundingClientRect(),this.padding],box=ref$[0],p=ref$[1];x=box.x-p+window.scrollX;y=box.y-p+window.scrollY;import$(this.box.style,{left:x+"px",top:y+"px",width:box.width+p*2+"px",height:box.height+p*2+"px"});if(this.box.classList.contains("active")){this.box.classList.add("moving")}return this.box.classList.add("active")}});renderinfo={list:[],running:false,render:function(){return this.list.map(function(it){return it.render()})},tick:function(){var this$=this;if(!renderinfo.running){return}return setTimeout(function(){return requestAnimationFrame(function(){return this$.render()})},500)},add:function(it){this.list.push(it);if(this.running){return}this.running=true;return this.render()}};window.addEventListener("scroll",function(){return renderinfo.render()});if(typeof module!="undefined"&&module!==null){module.exports=main}if(typeof window!="undefined"&&window!==null){window.focalbox=main}function import$(obj,src){var own={}.hasOwnProperty;for(var key in src)if(own.call(src,key))obj[key]=src[key];return obj}}).call(this);

@@ -6,3 +6,3 @@ {

"description": "a box for highlighting your current focus",
"version": "0.0.2",
"version": "0.0.3",
"files": [

@@ -9,0 +9,0 @@ "dist/**/*"

@@ -29,5 +29,6 @@ # focalbox

- focus(enable): set enable to true if to enter focus mode.
- add-host(hosts): add elements ( Element or Array of Element ) as focalbox hosts.
- remove-host(host): remove elements ( Element or Array of Element ) from focalbox hosts.
- set-target(node): target `node` with focalbox
- isFocused(): return true if focalbox is in focus mode
- addHost(hosts): add elements ( Element or Array of Element ) as focalbox hosts.
- removeHost(host): remove elements ( Element or Array of Element ) from focalbox hosts.
- setTarget(node): target `node` with focalbox
- render: update focalbox

@@ -34,0 +35,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc