我正在使用 Angular 并在 JavaScript 的帮助下开发了一个可点击的进度条(这是我能做到的最好的)。
有没有办法将滑块放置在进度条内但不干扰进度可视化?
堆栈闪电战 https://stackblitz.com/edit/angular-jjb7gh?file=src%2Fapp%2Fapp.component.ts
HTML
<div class="progress aqua" data-width="0%">
<div class="progress-text">0%</div>
<div class="progress-bar">
<div class="progress-text">0%</div>
</div>
</div>
<input class="slider" id="slider" type="range" name="slider" min="0" max="100" value="0">
成分
myfuction(){
$(document).ready(function( $ ) {
$('#slider').on('input',function(e) {
$('.progress-bar').css('width',(e.target as HTMLInputElement).value + '%');
});
// create an observer instance
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type == 'attributes' && mutation.attributeName == 'style') {
var el = (mutation.target as HTMLInputElement);
var width = el.style.width;
var $parentEl =$(el).parent('.progress');
$parentEl.attr('data-width',width);
$parentEl.find('.progress-text').text(width);
}
});
});
// configuration of the observer
var config = {
attributes: true,
attributeFilter: ['style'],
childList: false,
characterData: false
};
$('.progress-bar').each(function(e) {
// pass in the target node, as well as the observer options
observer.observe(this, config);
})
});
}
Image https://i.stack.imgur.com/Ugh1u.png
目标是通过点击来增加进度,即使我使用滑块来做到这一点,但如果可以删除滑块并使进度条功能更好。