调整jQuery进度目标表,使其包含待处理表
Adapt jQuery progress goal meter to include pending meter
我正试图调整GoalMeter jQuery插件,以包括一个可与进度计一起显示的待定计。我创建了一个CodePen,并做了一些调整,可以在这里查看:http://codepen.io/mikehermary/pen/xwEypo
update: function goalMeter_update(options) {
if (typeof options === "object") {
this.extendOptions(options);
}
// Get ze values
this.goalAmount = this.getGoalAmount();
this.progressAmount = this.getProgressAmount();
this.pendingAmount = this.getPendingAmount();
// Apply some math to this stuff.
this.progressPercentageAmount = Math.min(
Math.round(
this.progressAmount / this.goalAmount * 1000
) / 10, 100
); //make sure we have 1 decimal point :)
// figure out the new width/height
this.newCSS[ this.isHorizontal ? "width" : "height" ] = this.progressPercentageAmount + "%";
// render stuff. Yeah.
this.render();
// Apply some math to this stuff.
this.pendingPercentageAmount = Math.min(
Math.round(
this.pendingAmount / this.goalAmount * 1000
) / 10, 100
); //make sure we have 1 decimal point :)
// figure out the new width/height
this.newCSS[ this.isHorizontal ? "width" : "height" ] = this.pendingPercentageAmount + "%";
// render stuff. Yeah.
this.render();
},
这是控制米及其垂直高度的函数。正如您在CodePen示例中看到的,挂起的仪表覆盖了捐赠的仪表。怎样才能使每个仪表独立?
经过一些小小的挠头和试错,我终于弄明白了。通过将仪表水平或垂直显示的newCSS更改为progressCSS和pendingCSS,然后删除第一个this,解决了这个问题。render函数调用。在这些变化之后,仪表的工作和动画相互独立。
然后我计算出每个仪表的z指数需要切换,这取决于哪个值更低。如果进度值较低,则需要比pending更高的z-index,反之亦然。我附加了上一个示例中的更新函数来显示我的更改。
update: function goalMeter_update(options) {
if (typeof options === "object") {
this.extendOptions(options);
}
// Get the values
this.goalAmount = this.getGoalAmount();
this.progressAmount = this.getProgressAmount();
this.pendingAmount = this.getPendingAmount();
// Apply some math to this stuff.
this.progressPercentageAmount = Math.min(
Math.round(
this.progressAmount / this.goalAmount * 1000
) / 10, 100
); //make sure we have 1 decimal point :)
// figure out the new width/height
this.progressCSS[ this.isHorizontal ? "width" : "height" ] = this.progressPercentageAmount + "%";
// Apply some math to this stuff.
this.pendingPercentageAmount = Math.min(
Math.round(
this.pendingAmount / this.goalAmount * 1000
) / 10, 100
); //make sure we have 1 decimal point :)
// figure out the new width/height
this.pendingCSS[ this.isHorizontal ? "width" : "height" ] = this.pendingPercentageAmount + "%";
// Set the z-index values
if (this.progressAmount > this.pendingAmount) {
this.progressCSS[ "z-index" ] = "1";
}
if (this.progressAmount < this.pendingAmount) {
this.pendingCSS[ "z-index" ] = "1";
}
// render stuff. Yeah.
this.render();
},
我希望这可能对任何希望与此插件或jQuery实现相同结果的人有所帮助。
相关文章:
- 如何更改:包含以处理精确的字符串
- 在动态创建的元素中包含参数的事件处理程序
- 执行批处理文件的Javascript,该文件包含基于每个会话的环境变量设置
- 句柄中包含括号的问题处理属性
- 如何在事件处理程序中包含函数(及其参数),而不在页面加载时调用该函数
- javascript没有't处理包含的html文件中的html元素
- 我们如何处理包含带有秘银的子数组的数据模型
- jQuery将事件处理程序绑定到具有包含元素的多个元素
- 如何使用角度翻译处理包含 HTML 的字符串
- 对容器中的项目进行动画处理,以动画化并包含 100% 的容器
- 如何在咖啡脚本中预处理或包含咖啡脚本
- 将承诺置于待处理状态
- 有没有更好的方法将 jquery 事件处理程序包含在 xmlhttprequest() 中
- 我想制作我的表单,当他们发送时,它会自动在表格上显示“待处理”值
- 对于小型的自包含事件处理函数,可以使用内联javascript吗
- javascript包含无法处理chrome的内容
- 如何获得待处理承诺的数量
- 调整jQuery进度目标表,使其包含待处理表
- Javascript AJAX待处理请求
- 如何按总数、待处理、完成、进行中、接受来显示用户描述/测试用例的数量