├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .nvmrc ├── README.md ├── demo.gif ├── index.html ├── logo.png ├── package.json ├── src └── index.ts ├── tsconfig.json └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | dist 2 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | const restrictedGlobals = [ 2 | "addEventListener", 3 | "blur", 4 | "close", 5 | "closed", 6 | "confirm", 7 | "defaultStatus", 8 | "defaultstatus", 9 | "event", 10 | "external", 11 | "find", 12 | "focus", 13 | "frameElement", 14 | "frames", 15 | "history", 16 | "innerHeight", 17 | "innerWidth", 18 | "length", 19 | "location", 20 | "locationbar", 21 | "menubar", 22 | "moveBy", 23 | "moveTo", 24 | "name", 25 | "onblur", 26 | "onerror", 27 | "onfocus", 28 | "onload", 29 | "onresize", 30 | "onunload", 31 | "open", 32 | "opener", 33 | "opera", 34 | "outerHeight", 35 | "outerWidth", 36 | "pageXOffset", 37 | "pageYOffset", 38 | "parent", 39 | "print", 40 | "removeEventListener", 41 | "resizeBy", 42 | "resizeTo", 43 | "screen", 44 | "screenLeft", 45 | "screenTop", 46 | "screenX", 47 | "screenY", 48 | "scroll", 49 | "scrollbars", 50 | "scrollBy", 51 | "scrollTo", 52 | "scrollX", 53 | "scrollY", 54 | "self", 55 | "status", 56 | "statusbar", 57 | "stop", 58 | "toolbar", 59 | "top", 60 | ]; 61 | 62 | module.exports = { 63 | extends: ["eslint:recommended"], 64 | root: true, 65 | // parser: "babel-eslint", 66 | plugins: ["import"], 67 | env: { 68 | browser: true, 69 | commonjs: true, 70 | es6: true, 71 | jest: true, 72 | node: true, 73 | }, 74 | parserOptions: { 75 | ecmaVersion: 2018, 76 | sourceType: "module", 77 | }, 78 | overrides: [ 79 | { 80 | files: ["**/*.ts?(x)"], 81 | parser: "@typescript-eslint/parser", 82 | parserOptions: { 83 | ecmaVersion: 2018, 84 | sourceType: "module", 85 | 86 | // typescript-eslint specific options 87 | warnOnUnsupportedTypeScriptVersion: true, 88 | }, 89 | plugins: ["@typescript-eslint"], 90 | // If adding a typescript-eslint version of an existing ESLint rule, 91 | // make sure to disable the ESLint rule here. 92 | rules: { 93 | // 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/291) 94 | "no-dupe-class-members": 0, 95 | // 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/477) 96 | "no-undef": 0, 97 | 98 | // Add TypeScript specific rules (and turn off ESLint equivalents) 99 | "@typescript-eslint/consistent-type-assertions": 1, 100 | "no-array-constructor": 0, 101 | "@typescript-eslint/no-array-constructor": 1, 102 | "no-use-before-define": 0, 103 | "@typescript-eslint/no-use-before-define": [ 104 | 1, 105 | { 106 | functions: false, 107 | classes: false, 108 | variables: false, 109 | typedefs: false, 110 | }, 111 | ], 112 | "no-unused-expressions": 0, 113 | "@typescript-eslint/no-unused-expressions": [ 114 | 2, 115 | { 116 | allowShortCircuit: true, 117 | allowTernary: true, 118 | allowTaggedTemplates: true, 119 | }, 120 | ], 121 | "no-unused-vars": 0, 122 | "@typescript-eslint/no-unused-vars": [ 123 | 1, 124 | { 125 | args: "none", 126 | ignoreRestSiblings: true, 127 | }, 128 | ], 129 | "no-useless-constructor": 0, 130 | "@typescript-eslint/no-useless-constructor": 1, 131 | }, 132 | }, 133 | ], 134 | 135 | // NOTE: When adding rules here, you need to make sure they are compatible with 136 | // `typescript-eslint`, as some rules such as `no-array-constructor` aren't compatible. 137 | rules: { 138 | // http://eslint.org/docs/rules/ 139 | "array-callback-return": 1, 140 | "default-case": 0, 141 | "dot-location": [1, "property"], 142 | eqeqeq: [1, "smart"], 143 | "new-parens": 1, 144 | "no-array-constructor": 0, 145 | "no-caller": 1, 146 | "no-cond-assign": [1, "except-parens"], 147 | "no-const-assign": 1, 148 | "no-control-regex": 1, 149 | "no-delete-var": 1, 150 | "no-dupe-args": 1, 151 | "no-dupe-class-members": 1, 152 | "no-dupe-keys": 1, 153 | "no-duplicate-case": 1, 154 | "no-empty-character-class": 1, 155 | "no-empty-pattern": 1, 156 | "no-eval": 1, 157 | "no-ex-assign": 1, 158 | "no-extend-native": 1, 159 | "no-extra-bind": 1, 160 | "no-extra-label": 1, 161 | "no-fallthrough": 1, 162 | "no-func-assign": 1, 163 | "no-implied-eval": 1, 164 | "no-invalid-regexp": 1, 165 | "no-iterator": 1, 166 | "no-label-var": 1, 167 | "no-labels": [1, { allowLoop: true, allowSwitch: false }], 168 | "no-lone-blocks": 1, 169 | "no-loop-func": 1, 170 | "no-mixed-operators": [ 171 | 1, 172 | { 173 | groups: [ 174 | ["&", "|", "^", "~", "<<", ">>", ">>>"], 175 | ["==", "!=", "===", "!==", ">", ">=", "<", "<="], 176 | ["&&", "||"], 177 | ["in", "instanceof"], 178 | ], 179 | allowSamePrecedence: false, 180 | }, 181 | ], 182 | "no-multi-str": 1, 183 | "no-native-reassign": 1, 184 | "no-negated-in-lhs": 1, 185 | "no-new-func": 1, 186 | "no-new-object": 1, 187 | "no-new-symbol": 1, 188 | "no-new-wrappers": 1, 189 | "no-obj-calls": 1, 190 | "no-octal": 1, 191 | "no-octal-escape": 1, 192 | "no-regex-spaces": 1, 193 | "no-restricted-syntax": [1, "WithStatement"], 194 | "no-script-url": 1, 195 | "no-self-assign": 1, 196 | "no-self-compare": 1, 197 | "no-sequences": 1, 198 | "no-shadow-restricted-names": 1, 199 | "no-sparse-arrays": 1, 200 | "no-template-curly-in-string": 1, 201 | "no-this-before-super": 1, 202 | "no-throw-literal": 1, 203 | "no-undef": 2, 204 | "no-restricted-globals": [2].concat(restrictedGlobals), 205 | "no-unreachable": 1, 206 | "no-unused-expressions": [ 207 | 2, 208 | { 209 | allowShortCircuit: true, 210 | allowTernary: true, 211 | allowTaggedTemplates: true, 212 | }, 213 | ], 214 | "no-unused-labels": 1, 215 | "no-unused-vars": [ 216 | 1, 217 | { 218 | args: "none", 219 | ignoreRestSiblings: true, 220 | }, 221 | ], 222 | "no-use-before-define": [ 223 | 1, 224 | { 225 | functions: false, 226 | classes: false, 227 | variables: false, 228 | }, 229 | ], 230 | "no-useless-computed-key": 1, 231 | "no-useless-concat": 1, 232 | "no-useless-constructor": 1, 233 | "no-useless-escape": 1, 234 | "no-useless-rename": [ 235 | 1, 236 | { 237 | ignoreDestructuring: false, 238 | ignoreImport: false, 239 | ignoreExport: false, 240 | }, 241 | ], 242 | "no-with": 1, 243 | "no-whitespace-before-property": 1, 244 | "require-yield": 1, 245 | "rest-spread-spacing": [1, "never"], 246 | strict: [1, "never"], 247 | "unicode-bom": [1, "never"], 248 | "use-isnan": 1, 249 | "valid-typeof": 1, 250 | "getter-return": 1, 251 | 252 | // // https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules 253 | "import/first": 2, 254 | "import/no-amd": 2, 255 | "import/no-anonymous-default-export": 1, 256 | "import/no-webpack-loader-syntax": 2, 257 | }, 258 | }; 259 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | npm-debug.log* 4 | yarn-error.log* 5 | .vscode 6 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
8 | Observe the rect of a DOM element. 9 |
10 | 11 | 15 | 16 |
17 |
18 |
21 | You need to run this from a file server. 22 | 23 | From the root of this project run 24 | 25 | $ serve 26 | 27 | then open up http://localhost:5000/example.html. 28 |29 | 30 | 31 |