MCPcopy Create free account
hub / github.com/dcloudio/mui / showTip

Function showTip

js/input.plugin.js:124–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

122 var tooltip = this.sliderAction;
123 var timer = null;
124 var showTip = function() { //每次重新计算是因为控件可能被隐藏,初始化时计算是不正确的
125 tooltip.classList.remove(CLASS_HIDDEN);
126 var offsetLeft = element.offsetLeft;
127 var width = element.offsetWidth - 28;
128 var tooltipWidth = tooltip.offsetWidth;
129 var distince = Math.abs(element.max - element.min);
130 var scaleWidth = (width / distince) * Math.abs(element.value - element.min);
131 tooltip.style.left = (14 + offsetLeft + scaleWidth - tooltipWidth / 2) + 'px';
132 tooltip.innerText = element.value;
133 if (timer) {
134 clearTimeout(timer);
135 }
136 timer = setTimeout(function() {
137 tooltip.classList.add(CLASS_HIDDEN);
138 }, 1000);
139 };
140 element.addEventListener('input', showTip);
141 element.addEventListener('tap', showTip);
142 element.addEventListener($.EVENT_MOVE, function(e) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected