|
|
@ -94,7 +94,8 @@ |
|
|
|
var toggleWidth = toggle.clientWidth; |
|
|
|
var toggleWidth = toggle.clientWidth; |
|
|
|
var handleWidth = handle.clientWidth; |
|
|
|
var handleWidth = handle.clientWidth; |
|
|
|
var offset = (toggleWidth - handleWidth); |
|
|
|
var offset = (toggleWidth - handleWidth); |
|
|
|
var slideOn = (!touchMove && !toggle.classList.contains('active')) || (touchMove && (distanceX > (toggleWidth / 2 - handleWidth / 2))); |
|
|
|
var originOn = toggle.classList.contains('active'); |
|
|
|
|
|
|
|
var slideOn = (!touchMove && !originOn) || (touchMove && (distanceX > (toggleWidth / 2 - handleWidth / 2))); |
|
|
|
|
|
|
|
|
|
|
|
if (slideOn) { |
|
|
|
if (slideOn) { |
|
|
|
handle.style[transformProperty] = 'translate3d(' + offset + 'px,0,0)'; |
|
|
|
handle.style[transformProperty] = 'translate3d(' + offset + 'px,0,0)'; |
|
|
@ -104,6 +105,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
toggle.classList[slideOn ? 'add' : 'remove']('active'); |
|
|
|
toggle.classList[slideOn ? 'add' : 'remove']('active'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (originOn != slideOn) { |
|
|
|
e = new CustomEvent('toggle', { |
|
|
|
e = new CustomEvent('toggle', { |
|
|
|
detail: { |
|
|
|
detail: { |
|
|
|
isActive: slideOn |
|
|
|
isActive: slideOn |
|
|
@ -113,6 +115,7 @@ |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
toggle.dispatchEvent(e); |
|
|
|
toggle.dispatchEvent(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
touchMove = false; |
|
|
|
touchMove = false; |
|
|
|
toggle = false; |
|
|
|
toggle = false; |
|
|
|