Skip to content

Commit c080e01

Browse files
committed
Initial commit
0 parents  commit c080e01

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist
2+
node_modules
3+
npm-debug.log
4+
.DS_Store

index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const CSS = 'position:absolute;left:0;top:-100%;width:100%;height:100%;margin:1px 0 0;border:none;opacity:0;visibility:hidden;pointer-events:none;';
2+
3+
export default (element, handler) => {
4+
let frame = document.createElement('iframe');
5+
frame.style.cssText = CSS;
6+
element.appendChild(frame);
7+
frame.contentWindow.onresize = () => {
8+
handler.call(element);
9+
};
10+
return frame;
11+
}

package.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "simple-element-resize-detector",
3+
"amdName": "simpleElementResizeDetector",
4+
"version": "1.0.0",
5+
"description": "Observes resizing of an element using a hidden iframe.",
6+
"main": "dist/simple-element-resize-detector.js",
7+
"jsnext:main": "index.js",
8+
"scripts": {
9+
"build": "npm-run-all transpile minify size",
10+
"transpile": "rollup -c rollup.config.js",
11+
"minify": "uglifyjs $npm_package_main -cm -o $npm_package_main -p relative --in-source-map ${npm_package_main}.map --source-map ${npm_package_main}.map",
12+
"size": "echo \"gzip size: $(gzip-size $npm_package_main | pretty-bytes)\"",
13+
"test": "eslint src test",
14+
"prepublish": "npm-run-all build test",
15+
"release": "npm run -s build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
16+
},
17+
"files": [
18+
"index.js",
19+
"dist"
20+
],
21+
"keywords": [],
22+
"repository": {
23+
"type": "git",
24+
"url": "git+https://github.com/developit/simple-element-resize-detector.git"
25+
},
26+
"author": "Jason Miller <jason@developit.ca>",
27+
"license": "MIT",
28+
"devDependencies": {
29+
"babel-core": "^6.6.4",
30+
"babel-eslint": "^7.0.0",
31+
"babel-preset-es2015": "^6.9.0",
32+
"babel-preset-stage-0": "^6.5.0",
33+
"eslint": "^3.1.0",
34+
"gzip-size-cli": "^1.0.0",
35+
"mkdirp": "^0.5.1",
36+
"npm-run-all": "^2.3.0",
37+
"pretty-bytes-cli": "^1.0.0",
38+
"rollup": "^0.36.3",
39+
"rollup-plugin-babel": "^2.4.0",
40+
"rollup-plugin-es3": "^1.0.3",
41+
"uglify-js": "^2.6.2"
42+
}
43+
}

rollup.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import path from 'path';
2+
import fs from 'fs';
3+
import babel from 'rollup-plugin-babel';
4+
import es3 from 'rollup-plugin-es3';
5+
6+
let pkg = JSON.parse(fs.readFileSync('./package.json'));
7+
8+
export default {
9+
entry: pkg['jsnext:main'],
10+
dest: pkg.main,
11+
sourceMap: path.resolve(pkg.main),
12+
moduleName: pkg.amdName,
13+
useStrict: false,
14+
exports: 'default',
15+
format: 'umd',
16+
plugins: [
17+
babel({
18+
babelrc: false,
19+
comments: false,
20+
presets: [
21+
['es2015', { loose:true, modules:false }],
22+
'stage-0'
23+
]
24+
}),
25+
es3()
26+
]
27+
};

0 commit comments

Comments
 (0)