Comments (6)
@Hujianboo My thought is the following:
max-row
is a prop to trigger whether is usingline-clamp
styles, its default value should benull
. Ellipsis will turn on the multiple rows ellipsis whenmax-row
is specified to a number (> 1), Ellipsis will work like before when this feature not effective.With multiple rows, we should add a special class named
nh.bm('multiple')
, and can usewrapper.value.scrollHeight > wrapper.value.offsetHeight
to judge whether to show tooltip.The added class name will effect some styles:
.#{$namespace}-ellipsis { @include basis; display: inline-block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; &--multiple { display: -webkit-inline-box; -webkit-box-orient: vertical; text-overflow: unset; // or clip white-space: unset; // or normal } &__tip { padding: 8px 14px 10px; } }
In my opinion,
line-clamp
is a vertical layout, it is difference totext-overflow
which is horizonal layout, so we should not usingline-clamp
when in single row.
Thx.Agree with you. My solution is hurry and the logic of whether to display tooltip is false. Can I add this feature when I have time ?
from vexip-ui.
Does it mean that the component has one option named maxRow to decide the max displayed lines ? Do you mind using scss variable and @if rule to achieve it
from vexip-ui.
@Hujianboo yes, it should be add a prop to specify the max line count, max-row
is ok.
My initial consideration is using -webkit-line-clamp
to implement this feature. I had not know where it is needed to use the scss variables and @if
rule?
from vexip-ui.
@Hujianboo yes, it should be add a prop to specify the max line count,
max-row
is ok.My initial consideration is using
-webkit-line-clamp
to implement this feature. I had not know where it is needed to use the scss variables and@if
rule?
I'm sorry that I didn't look at the structure carefully. It can be implemented without SCSS variables. What I thought before is that if there are multiple lines, using webkit ,otherwise it will remain the original logic .But it seems that there is no problem that just -webkit for all.
I just tried to use webkit. It seems that the range
in the logic of calculating the width is invalid, and the original width cannot be calculated while the target is using webkit. https://github.com/qmhc/vexip-ui/blob/2aeca227976e5b7a116b23ef31a68299a4b876b7/components/ellipsis/ellipsis.vue#L128 Because I am not familiar with range
, I directly cloned the old DOM to calculate the real width to implement it and the new Dom will be removed after calculation.
function handleTriggerEnter() {
window.clearTimeout(timer.hover)
timer.hover = window.setTimeout(() => {
if (!wrapper.value || !wrapper.value.childNodes.length) {
visible.value = false
return
}
const dom = wrapper.value.cloneNode(true)
dom.style.position = 'fixed'
dom.style.top = '-999999px'
dom.style.width = 'auto'
document.body.appendChild(dom)
visible.value = dom.clientWidth > wrapper.value.getBoundingClientRect().width
content.value = visible.value ? wrapper.value.textContent ?? '' : ''
dom.remove()
nextTick(() => {
active.value = true
})
}, 250)
}
Do you have another idea to solve the problem?
--------add-------
the ellpsis.scss
@use './design' as *;
@use './tooltip.scss';
.#{$namespace}-ellipsis {
@include basis;
width: 100%;
overflow: hidden;
display: -webkit-inline-box;
-webkit-box-orient: vertical;
&__tip {
padding: 8px 14px 10px;
}
}
the template
<div
ref="wrapper"
:class="nh.b()"
v-bind="$attrs"
:style="{
'-webkit-line-clamp': props.displayNum //default value is 1
}"
@mouseenter="handleTriggerEnter"
@mouseleave="handleTriggerLeave"
>
<slot></slot>
</div>
from vexip-ui.
@Hujianboo My thought is the following:
max-row
is a prop to trigger whether is using line-clamp
styles, its default value should be null
. Ellipsis will turn on the multiple rows ellipsis when max-row
is specified to a number (> 1), Ellipsis will work like before when this feature not effective.
With multiple rows, we should add a special class named nh.bm('multiple')
, and can use wrapper.value.scrollHeight > wrapper.value.offsetHeight
to judge whether to show tooltip.
The added class name will effect some styles:
.#{$namespace}-ellipsis {
@include basis;
display: inline-block;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
&--multiple {
display: -webkit-inline-box;
-webkit-box-orient: vertical;
text-overflow: unset; // or clip
white-space: unset; // or normal
}
&__tip {
padding: 8px 14px 10px;
}
}
In my opinion, line-clamp
is a vertical layout, it is difference to text-overflow
which is horizonal layout, so we should not using line-clamp
when in single row.
from vexip-ui.
@Hujianboo You're very welcome!
from vexip-ui.
Related Issues (20)
- 还是AutoComplete的bug
- [Select]: disabled with multiple can still be changed.
- [Select]: template #selected is ignored with prop 'filter' HOT 1
- Tree suffix & prefix could be parts of Data[] using h() function HOT 3
- Tree貌似树的结构解析和视图渲染有点问题 HOT 7
- [select]: Option label overflow from select with multiple / max-tag-count props
- Missing / bad translations
- [Select]: Wrong kind of value passed to 'selected' slot HOT 1
- [Feature Request] tag 可否为prefix、suffix增加undivied属性,以选择性隐藏分隔符? HOT 4
- 有没有办法和其他的UI框架混用 HOT 6
- Alert、Reslut、Timeline 增加独立的 `info` 类型 HOT 3
- Image组件Bug HOT 17
- Drawer event 'show' is emitted twice without any action HOT 2
- 使用nuxt,build之后样式不正确 HOT 1
- Hydration warning , when using the Drawer in Nuxt HOT 1
- when refresh page upload component can not select file.
- Hydration attribute mismatch, when using the Modal in Nuxt 3 HOT 2
- Layout组件部分小问题 HOT 15
- formItem defaultValue 属性不能正常使用
- 【Bug】InputNumber incorrect value when using precision & sync HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vexip-ui.