Skip to content

aykutonen/dom-inspector

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DomInspector

Dom inspector like chrome dev tools.

Usage

Install dom-inspector

npm install dom-inspector --save
<script type="text/javascript" src="./dist/dom-inspector.min.js"></script>
const DomInspector = require('dom-inspector');
import DomInspector from 'dom-inspector';

New instance

const inspector = new DomInspector();

Instance options

const inspector = new DomInspector({
	root: 'body',
	theme: 'you-custom-theme-class'
});
  • root

    Dom inspector root element. String or Dom, default body mean $('body').

  • theme

    Inspector overlay style. You can custom overlay background color as follow.

     .you-custom-theme-class .margin {
     	background-color: blue;
     }
    
     .you-custom-theme-class .border {
     	background-color: red;
     }
    
     .you-custom-theme-class .padding {
     	background-color: green;
     }
    
     .you-custom-theme-class .content {
     	background-color: gray;
     }

    Don`t forget background color opacity. ^_^

Attribute list

  • inspector.target

    Inspecting element.

API list

  • inspector.enable()

    Display overlay block and addEventListener mousemove.

  • inspector.pause()

    RemoveEventListener mousemove, pause inspector.

  • inspector.disable()

    RemoveEventListener mousemove, display overlay none.

  • inspector.destory()

    disable() and remove overlay.

  • inspector.getXPath([ele])

    Return ele XPath.

  • inspector.getSelector([ele])

    Return ele selector.

    html>body>div:nth-of-type(9)

  • inspector.getElementInfo([ele])

     return {
     	top: '',
     	left: '',
     	width: '',
     	height: '',
     	'padding-top': '',
     	'padding-right': '',
     	'padding-bottom': '',
     	'padding-left': '',
     	'border-top-width': '',
     	'border-right-width': '',
     	'border-bottom-width': '',
     	'border-left-width': '',
     	'margin-top': '',
     	'margin-right': '',
     	'margin-bottom': '',
     	'margin-left': ''
     };

About

Dom inspect like chrome dev tools.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 79.0%
  • HTML 13.5%
  • CSS 7.5%