larryzhu-dev / autofit.js Goto Github PK
View Code? Open in Web Editor NEWautofit.js 迄今为止最易用的自适应工具
Home Page: https://larryzhu-dev.github.io/autoLarryPages/autofit.js/
License: MIT License
autofit.js 迄今为止最易用的自适应工具
Home Page: https://larryzhu-dev.github.io/autoLarryPages/autofit.js/
License: MIT License
上次反映的 日历插件问题值不加拖拽功能就还好,这次这个 element-plus 就难受了。 弹窗后会造成页面右侧留白,element-ui 版本弹窗没有这个问题。
演示地址
resize && (window.onresize = () => {
keepFit(designWidth, designHeight, dom, ignore);
})
建议改为
resize &&
window.addEventListener('resize', () => {
keepFit(designWidth, designHeight, dom, ignore)
})
根据readme中描述,使用autofit.js,能够自动的拉伸或者缩小,对于大屏开发来讲,的确解决了好多问题,这里有两个基础的地方不太明白:
根据设计稿进行页面开发,最外层容器的宽与高是用设计稿的像素还是百分比?还是两者兼可?
容器内部各个元素的宽高,以及padding,margin的值用像素还是百分比?css可定义的值太多了,px, rem ,vh/vw,em,这些在引用autofit.js的项目中,是可以混用,还是单纯便用px来统一开发?
大佬太赞了,前来膜拜,是否可以搞一个预览,能够直观的体验一下?
如果一个元素,在init之前是display none的,有没有add的方法将其加入自适应,比如antd的select组件,下拉前是不存在body中的,点开下拉后,和select的元素width没有同宽
正常路由跳转页面缩放正常,f5刷新页面会导致UI显示比例异常
添加全局缩放之后,再加高德地图进去,拖拽感觉不够丝滑了,而且缩放也不是以鼠标所在位置开始缩放,是什么问题呀?
vue环境,页面有双向绑定的事件,操作后,底部留白,改变浏览器高度,变正常
transform: scale(1.896);
后会导致单元格有白边。
已经使用使用 border-collapse: collapse;
合并了边框。
复现DEMO地址: https://codesandbox.io/s/autofit-demo-pkgzc6?file=/src/App.vue
let clientHeight = document.documentElement.clientHeight;
let clientWidth = document.documentElement.clientWidth;
有些大屏页面可能并不是撑满浏览器的,比如有菜单栏,头部导航栏。
能不能增加自定义容器customContainer,如下
let container =document.querySelector(options.customContainer)
let clientHeight = container.clientHeight;
let clientWidth = container .clientWidth;
echarts 图标偏移问题
使用transform: scale(0.465104); 会对页面el-dialog的蒙版影响,蒙版把元素当下面了,这个有解决办法么?
出错。
_autofit.init is not a function
currelRectification参数未赋值导致空选择器
在off方法中调用的document.querySelectorAll(currelRectification)
中并未用到传入的el参数也,会报错Uncaught DOMException: Failed to execute 'querySelectorAll' on 'Document': The provided selector is empty. at <anonymous>:1:27
想通过elRectification来忽略地图容器,但是报错:Cannot read properties of undefined (reading 'isAutofitRunnig')
onMounted(() => {
elRectification('#map');
});
使用ignore忽略地图容器,会造成地图显示不全,容器宽度设置的都是100%,请问使用elRectification是否可以解决这问题,不忽略的话地图会显得很模糊
请问这个autofit.js支持vue2嘛?
如题 window.devicePixelRatio 可以获取到系统缩放百分比
绑定Body后,Select的下拉弹窗位置错误了。如果不绑定body,绑定到body下面的元素,由于下拉框都是渲染到Body下的,下拉框又不会被缩放。
使用 autofitjs 后FullCalendar 本身得高度宽度自适应会出现偏差,外部拖拽事件会发生偏移。使用 ignore和elRectification 方式也不大好使。
"@fullcalendar/vue3": "^6.1.9"
"autofit.js": "^3.0.6"
演示地址
keepFit函数中let height = Math.round(clientHeight / currScale);let width = Math.round(clientWidth / currScale);如果currScale缩放比例是小于1的话,那缩小的情况下宽高不是更大了吗?不知道是不是这个原因导致的
如elementUI和各类UI库的弹出层,是基于屏幕坐标计算弹出层位置的,经过transform后,这些计算也会偏移,但是这些偏移是有迹可循的,一般是
鼠标移动距离左上角占真实屏幕的百分比 == 整个页面等比缩放后内部元素所在位置到左上角占缩放后元素的百分比
对此应该由第三方工具调整元素位置的计算策略,以真实的屏幕宽高计算元素位置,或者将弹出层以其父元素为基准偏移,并挂载在body内部。
虽然忽略可以解决点击位置偏移的问题,但是会导致地图中心点整体向右偏移,在低分辨下偏移更严重
我是vue2项目,我在app组件上用了所有button按钮点击后会出现灰色遮罩
mounted() {
autofit.init(
{
dh: 1080,
dw: 1920,
el: "#routerview-box",
resize: true,
ignore: [
{
el: ".gaodeMap",
},
],
},
false
);
},
beforeDestroy() {
autofit.off();
},
我用了下面的形式就没有了,不知道上面的形式是什么原因
mounted() {
autofit.init({
designHeight: 1080,
designWidth: 1920,
renderDom: "#app",
resize: true,
});
},
beforeDestroy() {
autofit.off();
},
缩放过小过大底部可能出现留白,大概1-2px..浏览器调试发现给#app 元素高度+2px 就行了
scale缩放值是小数会导致文字失真,有办法解决吗
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.