修改定位方式为固定定位,修正定位位置

This commit is contained in:
Theluyuan 2023-08-18 16:54:10 +08:00
parent 05dc278d28
commit e7e9ee2a65
8 changed files with 150692 additions and 41 deletions

View File

@ -1,4 +1,4 @@
const pkg = require('../package.json'); const pkg = require('../package.json');
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
@ -7,14 +7,14 @@ const {
CleanWebpackPlugin CleanWebpackPlugin
} = require('clean-webpack-plugin'); } = require('clean-webpack-plugin');
const isProd = process.env.NODE_ENV === 'prod'; const isProd = process.env.NODE_ENV === 'prod';
const banner = const banner =
`@Title: ${pkg.name} `@Title: ${pkg.name}
@Version: ${pkg.version} @Version: ${pkg.version}
@Description基于layui的多选解决方案 @Description基于layui的多选解决方案
@Site: https://gitee.com/maplemei/xm-select @Site: https://gitee.com/maplemei/xm-select
@Author: maplemei @Author: maplemei
@LicenseApache License 2.0`; @LicenseApache License 2.0`;
const webpackConfig = { const webpackConfig = {
@ -90,12 +90,12 @@ const webpackConfig = {
minify: { minify: {
collapseWhitespace: true collapseWhitespace: true
} }
}), }),
new webpack.BannerPlugin(banner), new webpack.BannerPlugin(banner),
new VueLoaderPlugin(), new VueLoaderPlugin(),
], ],
optimization: { optimization: {
minimize: true,//可以自行配置是否压缩 minimize: false,//可以自行配置是否压缩
}, },
devServer: { devServer: {
host: '0.0.0.0', host: '0.0.0.0',
@ -112,4 +112,4 @@ if (isProd) {
} }
module.exports = webpackConfig; module.exports = webpackConfig;

13469
dist/static/2.js vendored

File diff suppressed because one or more lines are too long

1126
dist/static/3.js vendored

File diff suppressed because one or more lines are too long

120375
dist/static/docs.js vendored

File diff suppressed because one or more lines are too long

8
dist/xm-select.js vendored

File diff suppressed because one or more lines are too long

9070
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

6638
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -414,7 +414,7 @@ class Framework extends Component{
}else }else
//聚焦label搜索框 //聚焦label搜索框
if(type === 'labelSearchBlur'){ if(type === 'labelSearchBlur'){
this.labelRef.blur(data); this.labelRef && this.labelRef.blur(data);
}else }else
//聚焦label搜索框 //聚焦label搜索框
if(type === 'labelSearch'){ if(type === 'labelSearch'){
@ -455,7 +455,9 @@ class Framework extends Component{
} }
calcPosition(){ calcPosition(){
if(this.state.show && this.props.model.type === 'fixed'){ if(!this.base || !this.state.show){
return {}
}
let rect = this.base.getBoundingClientRect(); let rect = this.base.getBoundingClientRect();
(Date.now() - this.state.time > 10) && this.setState({ time: Date.now() }) (Date.now() - this.state.time > 10) && this.setState({ time: Date.now() })
return { return {
@ -464,7 +466,6 @@ class Framework extends Component{
top: rect.y + rect.height + 4, top: rect.y + rect.height + 4,
width: rect.width, width: rect.width,
} }
}
return {}; return {};
} }
@ -600,6 +601,7 @@ class Framework extends Component{
} }
let rect = this.base.getBoundingClientRect(); let rect = this.base.getBoundingClientRect();
let bodyViewHeight;
if(direction === 'auto'){ if(direction === 'auto'){
//用于控制js获取下拉框的高度 //用于控制js获取下拉框的高度
this.bodyView.style.display = 'block'; this.bodyView.style.display = 'block';
@ -607,7 +609,7 @@ class Framework extends Component{
//获取下拉元素的高度 //获取下拉元素的高度
let bodyViewRect = this.bodyView.getBoundingClientRect(); let bodyViewRect = this.bodyView.getBoundingClientRect();
let bodyViewHeight = bodyViewRect.height; bodyViewHeight = bodyViewRect.height;
//还原控制效果 //还原控制效果
this.bodyView.style.display = ''; this.bodyView.style.display = '';
@ -619,13 +621,12 @@ class Framework extends Component{
let diff = clientHeight - y - rect.height - 20; let diff = clientHeight - y - rect.height - 20;
direction = diff > bodyViewHeight || y < diff ? 'down' : 'up'; direction = diff > bodyViewHeight || y < diff ? 'down' : 'up';
} }
if(direction == 'down'){ if(direction == 'down'){
this.bodyView.style.top = rect.height + 4 + 'px'; this.bodyView.style.top = (rect.height + 4 + rect.y )+ 'px';
this.bodyView.style.bottom = 'auto'; this.bodyView.style.bottom = 'auto';
}else{ }else{
this.bodyView.style.top = 'auto'; this.bodyView.style.top = (4 +rect.y - bodyViewHeight )+ 'px';
this.bodyView.style.bottom = rect.height + 4 + 'px'; this.bodyView.style.bottom = 'auto';
} }
} }