Refactoring
This commit is contained in:
parent
6f62faf5f3
commit
56288ced09
|
@ -343,26 +343,28 @@ define([
|
||||||
el.find('.track-center').width(me.options.width - 14);
|
el.find('.track-center').width(me.options.width - 14);
|
||||||
el.width(me.options.width);
|
el.width(me.options.width);
|
||||||
|
|
||||||
var centers = [];
|
|
||||||
var setCenters = function (index) {
|
var setCenters = function (index) {
|
||||||
if(!me.includeSnap) return;
|
if(!me.includeSnap) return;
|
||||||
centers = [50];
|
var n = me.minValue;
|
||||||
var n=0;
|
|
||||||
|
var getX = function (position) {
|
||||||
|
return (0.01 * me.width * position + me.cmpEl.offset().left + me._dragstart)/Common.Utils.zoom();
|
||||||
|
};
|
||||||
|
|
||||||
|
me.centers = [getX(50)];
|
||||||
_.each(me.thumbs, function (thumb, indexT) {
|
_.each(me.thumbs, function (thumb, indexT) {
|
||||||
if (indexT != index) {
|
if ((indexT != index) && (n != thumb.position)) {
|
||||||
centers.push((thumb.position - n) / 2 + n);
|
me.centers.push(getX((thumb.position - n) / 2 + n));
|
||||||
n = thumb.position;
|
n = thumb.position;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(n != 100) centers.push((100 - n) / 2 + n);
|
if(n != me.maxValue) me.centers.push(getX((me.maxValue - n) / 2 + n));
|
||||||
};
|
};
|
||||||
|
|
||||||
var resetPageX = function (e) {
|
var resetPageX = function (e) {
|
||||||
if(!me.includeSnap) return;
|
if(!me.includeSnap) return;
|
||||||
var x;
|
_.each(me.centers, function (x) {
|
||||||
_.each(centers, function (cnt){
|
if((e.pageX <= x + 10) && (e.pageX >= x - 10)) {
|
||||||
x=(0.01 * me.width * cnt + me.cmpEl.offset().left + me._dragstart)/Common.Utils.zoom();
|
|
||||||
if((e.pageX <= x + 10) && (e.pageX >= x-10)) {
|
|
||||||
e.pageX = x;
|
e.pageX = x;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -445,9 +447,9 @@ define([
|
||||||
|
|
||||||
var index = e.data.index,
|
var index = e.data.index,
|
||||||
thumb = me.thumbs[index].thumb;
|
thumb = me.thumbs[index].thumb;
|
||||||
setCenters(index);
|
|
||||||
|
|
||||||
me._dragstart = e.pageX*Common.Utils.zoom() - thumb.offset().left - thumb.width()/2;
|
me._dragstart = e.pageX*Common.Utils.zoom() - thumb.offset().left - thumb.width()/2;
|
||||||
|
setCenters(index);
|
||||||
me.setActiveThumb(index);
|
me.setActiveThumb(index);
|
||||||
|
|
||||||
_.each(me.thumbs, function (item, idx) {
|
_.each(me.thumbs, function (item, idx) {
|
||||||
|
|
Loading…
Reference in a new issue