Repository: amfe/lib-flexible
Branch: 2.0
Commit: 583b9cd404dd
Files: 5
Total size: 4.0 KB
Directory structure:
gitextract_3dzvmv48/
├── .editorconfig
├── .gitignore
├── README.md
├── index.js
└── package.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
# editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = off
indent_style = space
indent_size = 2
[{package.json,.travis.yml,.eslintrc*}]
indent_style = space
indent_size = 2
[*.md]
max_line_length = off
trim_trailing_whitespace = false
[COMMIT_EDITMSG]
max_line_length = off
================================================
FILE: .gitignore
================================================
# OS
.DS_Store
Thumbs.db
Desktop.ini
# IDE
.idea/
.vscode/
.project
*.swp
*.swo
# Dependency, Cache, Temporary
node_modules/
bower_components/
.svn/
.sass-cache/
.nodejs-cache/
npm-debug.log
# Distribution
coverage/
dist/
docs/
*.iml
================================================
FILE: README.md
================================================
# amfe-flexible
[Classic edition (0.3.2)](https://github.com/amfe/lib-flexible/tree/master)
> 由于`viewport`单位得到众多浏览器的兼容,`lib-flexible`这个过渡方案已经可以放弃使用,不管是现在的版本还是以前的版本,都存有一定的问题。建议大家开始使用`viewport`来替代此方。
## Usage
#### Install
`npm i -S amfe-flexible`
#### Import
```html
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<script src="./node_modules/amfe-flexible/index.js"></script>
```
You can inline this file with [inline-source](https://npmjs.org/package/inline-source).
#### Develop
Use [postcss-adaptive](https://www.npmjs.com/package/postcss-adaptive).
## License
(The MIT License)
Copyright (c) 2016 Alibaba MFE
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: index.js
================================================
(function flexible (window, document) {
var docEl = document.documentElement
var dpr = window.devicePixelRatio || 1
// adjust body font size
function setBodyFontSize () {
if (document.body) {
document.body.style.fontSize = (12 * dpr) + 'px'
}
else {
document.addEventListener('DOMContentLoaded', setBodyFontSize)
}
}
setBodyFontSize();
// set 1rem = viewWidth / 10
function setRemUnit () {
var rem = docEl.clientWidth / 10
docEl.style.fontSize = rem + 'px'
}
setRemUnit()
// reset rem unit on page resize
window.addEventListener('resize', setRemUnit)
window.addEventListener('pageshow', function (e) {
if (e.persisted) {
setRemUnit()
}
})
// detect 0.5px supports
if (dpr >= 2) {
var fakeBody = document.createElement('body')
var testElement = document.createElement('div')
testElement.style.border = '.5px solid transparent'
fakeBody.appendChild(testElement)
docEl.appendChild(fakeBody)
if (testElement.offsetHeight === 1) {
docEl.classList.add('hairlines')
}
docEl.removeChild(fakeBody)
}
}(window, document))
================================================
FILE: package.json
================================================
{
"name": "amfe-flexible",
"version": "2.2.1",
"description": "Build flexible page on mobile platform",
"keywords": [
"lib",
"amfe",
"flexible",
"mobile",
"css",
"rem",
"vw"
],
"homepage": "https://github.com/amfe/lib-flexible",
"repository": {
"type": "git",
"url": "git@github.com:amfe/lib-flexible.git"
},
"author": [
{
"name": "mingelz",
"email": "mingelz@gmail.com"
}
],
"scripts": {
"compress": "uglifyjs index.js -o index.min.js -c -m"
},
"dependencies": {},
"devDependencies": {
"uglify-js": "^3.0.27"
},
"license": "MIT"
}
gitextract_3dzvmv48/ ├── .editorconfig ├── .gitignore ├── README.md ├── index.js └── package.json
SYMBOL INDEX (2 symbols across 1 files)
FILE: index.js
function setBodyFontSize (line 6) | function setBodyFontSize () {
function setRemUnit (line 17) | function setRemUnit () {
Condensed preview — 5 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (5K chars).
[
{
"path": ".editorconfig",
"chars": 370,
"preview": "# editorconfig.org\n\nroot = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\ninsert_final_newline = true\ntrim_trailing_whitespa"
},
{
"path": ".gitignore",
"chars": 237,
"preview": "# OS\n.DS_Store\nThumbs.db\nDesktop.ini\n\n# IDE\n.idea/\n.vscode/\n.project\n*.swp\n*.swo\n\n# Dependency, Cache, Temporary\nnode_mo"
},
{
"path": "README.md",
"chars": 1721,
"preview": "# amfe-flexible\n\n[Classic edition (0.3.2)](https://github.com/amfe/lib-flexible/tree/master)\n\n> 由于`viewport`单位得到众多浏览器的兼容"
},
{
"path": "index.js",
"chars": 1139,
"preview": "(function flexible (window, document) {\n var docEl = document.documentElement\n var dpr = window.devicePixelRatio || 1\n"
},
{
"path": "package.json",
"chars": 628,
"preview": "{\n \"name\": \"amfe-flexible\",\n \"version\": \"2.2.1\",\n \"description\": \"Build flexible page on mobile platform\",\n \"keyword"
}
]
About this extraction
This page contains the full source code of the amfe/lib-flexible GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 5 files (4.0 KB), approximately 1.2k tokens, and a symbol index with 2 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.