Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var MAX_FILTER_PRICE = 1500;
- var makeDraggable = function (element, moveCallback) {
- element.addEventListener('mousedown', function (evt) {
- evt.preventDefault();
- var startPointerCoords = {
- x: evt.clientX
- };
- var startElementCoords = {
- x: element.offsetLeft
- };
- var onMouseMove = function (moveEvt) {
- moveEvt.preventDefault();
- var shift = {
- x: startPointerCoords.x - moveEvt.clientX
- };
- element.style.left = (startElementCoords.x - shift.x) + 'px';
- moveCallback && moveCallback();
- };
- var onMouseUp = function (upEvt) {
- upEvt.preventDefault();
- document.removeEventListener('mousemove', onMouseMove);
- document.removeEventListener('mouseup', onMouseUp);
- };
- document.addEventListener('mousemove', onMouseMove);
- document.addEventListener('mouseup', onMouseUp);
- });
- };
- var rangePriceMax = document.querySelector('.range__price--max');
- function updateMaxPrice(){
- var value = getSliderValue(btnRight);
- var price = value * MAX_FILTER_PRICE;
- price = Math.round(price);
- rangePriceMax.innerText = price;
- }
- makeDraggable(btnRight, updateMaxPrice);
- makeDraggable(btnLeft);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement