diff --git a/dist/rangeSlider.js b/dist/rangeSlider.js index 7a7d9ba..1c2f65e 100644 --- a/dist/rangeSlider.js +++ b/dist/rangeSlider.js @@ -274,7 +274,8 @@ throw new TypeError('element must be HTMLElement'); } name = name.trim(); - var event = new CustomEvent(name, data); + var event = document.createEvent('CustomEvent'); + event.initCustomEvent(name, false, false, data); el.dispatchEvent(event); } diff --git a/dist/rangeSlider.min.js b/dist/rangeSlider.min.js index 5a30939..125f479 100644 --- a/dist/rangeSlider.min.js +++ b/dist/rangeSlider.min.js @@ -1 +1 @@ -!function(t){"use strict";"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?t():window.rangeSlider=t()}(function(){"use strict";function t(){var t=document.createElement("input");return t.setAttribute("type","range"),"text"!==t.type}function e(t,e){var i=Array.prototype.slice.call(arguments,2);return setTimeout(function(){return t.apply(null,i)},e)}function i(t,e){return e=e||100,function(){if(!t.debouncing){var i=Array.prototype.slice.apply(arguments);t.lastReturnVal=t.apply(window,i),t.debouncing=!0}return clearTimeout(t.debounceTimeout),t.debounceTimeout=setTimeout(function(){t.debouncing=!1},e),t.lastReturnVal}}function n(t){return!(0!==t.offsetWidth&&0!==t.offsetHeight&&t.open!==!1)}function s(t){for(var e=[],i=t.parentNode;n(i);)e.push(i),i=i.parentNode;return e}function o(t,e){function i(t){"undefined"!=typeof t.open&&(t.open=t.open?!1:!0)}var n=s(t),o=n.length,r=[],h=t[e];if(o){for(var a=0;o>a;a++)r[a]=n[a].style.display,n[a].style.display="block",n[a].style.height="0",n[a].style.overflow="hidden",n[a].style.visibility="hidden",i(n[a]);h=t[e];for(var l=0;o>l;l++)i(n[l]),n[l].style.display=r[l],n[l].style.height="",n[l].style.overflow="",n[l].style.visibility=""}return h}function r(t){return t===""+t}function h(t){return null!==t&&void 0!==t&&(r(t)&&isFinite(parseFloat(t))||isFinite(t))}function a(){if(!arguments.length)return null;for(var t=0,e=arguments.length;e>t;t++)if(h(arguments[t]))return arguments[t]}function l(t){return"[object Object]"===Object.prototype.toString.call(t)}function u(t,e){var i,n={};for(i in t)n[i]=t[i];for(i in e)n[i]=e[i];return n}function d(t,e){for(var i in e)t.style[i]=e[i];return t.style}function p(t,e){v(t,e)||(t.className+=" "+e)}function f(t,e){var i=" "+t.className.replace(/[\t\r\n]/g," ")+" ";if(v(t,e)){for(;i.indexOf(" "+e+" ")>=0;)i=i.replace(" "+e+" "," ");t.className=i.replace(/^\s+|\s+$/g,"")}}function c(t,e,i){for(i&&e(t);t.parentNode&&!e(t);)t=t.parentNode;return t}function m(t,e,i){if(!r(e))throw new TypeError("event name must be String");if(!(t instanceof HTMLElement))throw new TypeError("element must be HTMLElement");e=e.trim();var n=new CustomEvent(e,i);t.dispatchEvent(n)}function v(t,e){return new RegExp(" "+e+" ").test(" "+t.className+" ")}function g(t,e){t.parentNode.insertBefore(e,t.nextSibling)}function b(t,e,i){e.forEach(function(e){t[x]||(t[x]={}),t[x][e]||(t[x][e]=[]),t.addEventListener(e,i,!1),t[x][e].indexOf(i)<0&&t[x][e].push(i)})}function y(t,e,i){e.forEach(function(e){t.removeEventListener(e,i,!1);var n;t[x]&&t[x][e]&&(n=t[x][e].indexOf(i))>-1&&t[x][e].splice(n,1)})}function _(t){function e(t){t===i._startEventListener&&this.el.removeEventListener(this.eventName,t,!1)}if(t[x]){var i=this;for(var n in t[x])t[x][n].forEach(e,{eventName:n,el:t});t[x]={}}}function E(t,e){var i,n,s;return this.element=t,this.options=u(X,e),this.polyfill=this.options.polyfill,this.onInit=this.options.onInit,this.onSlide=this.options.onSlide,this.onSlideStart=this.options.onSlideStart,this.onSlideEnd=this.options.onSlideEnd,this.onSlideEventsCount=-1,this.isInteractsNow=!1,this.needTriggerEvents=!1,!this.polyfill&&L?!1:(this.options.buffer=this.options.buffer||parseFloat(this.element.getAttribute("data-buffer")),this.identifier="js-"+C+"-"+P++,this.min=a(this.options.min,parseFloat(this.element.getAttribute("min")),i=0),this.max=a(this.options.max,parseFloat(this.element.getAttribute("max")),n=S),this.value=a(this.options.value,this.element.value,parseFloat(this.element.value||this.min+(this.max-this.min)/2)),this.step=a(this.options.step,parseFloat(this.element.getAttribute("step"))||(s=1)),this.percent=null,this._updatePercentFromValue(),this.toFixed=this._toFixed(this.step),this.fill=document.createElement("div"),this.fill.className=this.options.fillClass,this.handle=document.createElement("div"),this.handle.className=this.options.handleClass,this.range=document.createElement("div"),this.range.className=this.options.rangeClass,this.range.id=this.identifier,this.range.appendChild(this.handle),this.range.appendChild(this.fill),this.options.bufferClass&&(this.buffer=document.createElement("div"),this.buffer.className=this.options.bufferClass,this.range.appendChild(this.buffer)),h(this.options.value)&&(this._setValue(this.options.value,!0),this.element.value=this.options.value),h(this.options.buffer)&&this.element.setAttribute("data-buffer",this.options.buffer),(h(this.options.min)||i)&&this.element.setAttribute("min",""+this.min),(h(this.options.max)||n)&&this.element.setAttribute("max",""+this.max),(h(this.options.step)||s)&&this.element.setAttribute("step",""+this.step),g(this.element,this.range),d(this.element,{position:"absolute",width:"1px",height:"1px",overflow:"hidden",opacity:"0"}),this._handleDown=this._handleDown.bind(this),this._handleMove=this._handleMove.bind(this),this._handleEnd=this._handleEnd.bind(this),this._startEventListener=this._startEventListener.bind(this),this._changeEventListener=this._changeEventListener.bind(this),this._handleResize=this._handleResize.bind(this),this._init(),window.addEventListener("resize",this._handleResize,!1),b(document,this.options.startEvent,this._startEventListener),void this.element.addEventListener("change",this._changeEventListener,!1))}var x="eventListenerList",w=new RegExp("/[\\n\\t]/","g"),S=100,N=300,F=50,C="rangeSlider",P=0,L=t(),X={polyfill:!0,rangeClass:"rangeSlider",disabledClass:"rangeSlider--disabled",fillClass:"rangeSlider__fill",bufferClass:"rangeSlider__buffer",handleClass:"rangeSlider__handle",startEvent:["mousedown","touchstart","pointerdown"],moveEvent:["mousemove","touchmove","pointermove"],endEvent:["mouseup","touchend","pointerup"],min:null,max:null,step:null,value:null,buffer:null,borderRadius:10};return E.prototype.constructor=E,E.prototype._toFixed=function(t){return(t+"").replace(".","").length-1},E.prototype._init=function(){this.onInit&&"function"==typeof this.onInit&&this.onInit(),this._update()},E.prototype._updatePercentFromValue=function(){this.percent=(this.value-this.min)/(this.max-this.min)},E.prototype._startEventListener=function(t,e){var i=this,n=t.target,s=!1;c(n,function(t){return s=t.id===i.identifier&&!v(t,i.options.disabledClass)},!0),s&&this._handleDown(t,e)},E.prototype._changeEventListener=function(t,e){if(!e||e.origin!==this.identifier){var i=t.target.value,n=this._getPositionFromValue(i);this._setPosition(n)}},E.prototype._update=function(){this.handleWidth=o(this.handle,"offsetWidth"),this.rangeWidth=o(this.range,"offsetWidth"),this.maxHandleX=this.rangeWidth-this.handleWidth,this.grabX=this.handleWidth/2,this.position=this._getPositionFromValue(this.value),this.element.disabled?p(this.range,this.options.disabledClass):f(this.range,this.options.disabledClass),this._setPosition(this.position),this.options.bufferClass&&this.options.buffer&&this._setBufferPosition(this.options.buffer),this._updatePercentFromValue(),this.element.dispatchEvent(new Event("change"))},E.prototype._handleResize=function(){var t=this;return i(function(){e(function(){t._update()},N)},F)()},E.prototype._handleDown=function(t){if(this.isInteractsNow=!0,t.preventDefault(),b(document,this.options.moveEvent,this._handleMove),b(document,this.options.endEvent,this._handleEnd),!((" "+t.target.className+" ").replace(w," ").indexOf(this.options.handleClass)>-1)){var e=this._getRelativePosition(t),i=this.range.getBoundingClientRect().left,n=this._getPositionFromNode(this.handle)-i;this._setPosition(e-this.grabX),e>=n&&et?e:t>i?i:t},E.prototype._setPosition=function(t){var e,i;e=this._getValueFromPosition(this._cap(t,0,this.maxHandleX)),i=this._getPositionFromValue(e),this.fill.style.width=i+this.grabX+"px",this.handle.style.left=i+"px",this._setValue(e),this.position=i,this.value=e,this._updatePercentFromValue(),(this.isInteractsNow||this.needTriggerEventss)&&(this.onSlideStart&&"function"==typeof this.onSlideStart&&0===this.onSlideEventsCount&&this.onSlideStart(this.value,this.percent,this.position),this.onSlide&&"function"==typeof this.onSlide&&this.onSlide(this.value,this.percent,this.position)),this.onSlideEventsCount++},E.prototype._setBufferPosition=function(t){var e,i,n,s=!0;if(isFinite(t))t=parseFloat(t);else{if(!r(t))return void console.warn("New position must be XXpx or XX%");t.indexOf("px")>0&&(s=!1),t=parseFloat(t)}return isNaN(t)?void console.warn("New position is NaN"):this.options.bufferClass?(e=s?t:t/this.rangeWidth*100,0>e&&(e=0),e>100&&(e=100),this.options.buffer=e,i=this.options.borderRadius/this.rangeWidth*100,n=e-i,0>n&&(n=0),this.buffer.style.width=n+"%",this.buffer.style.left=.5*i+"%",void this.element.setAttribute("data-buffer",e)):void console.warn("You disabled buffer, it's className is empty")},E.prototype._getPositionFromNode=function(t){for(var e=0;null!==t;)e+=t.offsetLeft,t=t.offsetParent;return e},E.prototype._getRelativePosition=function(t){var e=this.range.getBoundingClientRect().left,i=0;return"undefined"!=typeof t.pageX?i=t.touches&&t.touches.length?t.touches[0].pageX:t.pageX:"undefined"!=typeof t.originalEvent.clientX?i=t.originalEvent.clientX:t.originalEvent.touches&&t.originalEvent.touches[0]&&"undefined"!=typeof t.originalEvent.touches[0].clientX?i=t.originalEvent.touches[0].clientX:t.currentPoint&&"undefined"!=typeof t.currentPoint.x&&(i=t.currentPoint.x),i-e},E.prototype._getPositionFromValue=function(t){var e,i;return e=(t-this.min)/(this.max-this.min),i=e*this.maxHandleX},E.prototype._getValueFromPosition=function(t){var e,i;return e=t/(this.maxHandleX||1),i=this.step*Math.round(e*(this.max-this.min)/this.step)+this.min,Number(i.toFixed(this.toFixed))},E.prototype._setValue=function(t,e){(t!==this.value||e)&&(this.element.value=t,this.value=t,m(this.element,"input",{origin:this.identifier}))},E.prototype.update=function(t,e){return e&&(this.needTriggerEvents=!0),l(t)&&(h(t.min)&&(this.element.setAttribute("min",""+t.min),this.min=t.min),h(t.max)&&(this.element.setAttribute("max",""+t.max),this.max=t.max),h(t.step)&&(this.element.setAttribute("step",""+t.step),this.step=t.step,this.toFixed=this._toFixed(t.step)),h(t.buffer)&&this._setBufferPosition(t.buffer),h(t.value)&&this._setValue(t.value)),this._update(),this.onSlideEventsCount=0,this.needTriggerEvents=!1,this},E.prototype.destroy=function(){_.call(this,document),window.removeEventListener("resize",this._handleResize,!1),this.element.removeEventListener("change",this._changeEventListener,!1),this.element.style.cssText="",delete this.element[C],this.range&&this.range.parentNode.removeChild(this.range)},E.create=function(t,e){function i(t){var i=t[C];i||(i=new E(t,e),t[C]=i)}t.length?Array.prototype.slice.call(t).forEach(function(t){i(t)}):i(t)},E}); \ No newline at end of file +!function(t){"use strict";"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?t():window.rangeSlider=t()}(function(){"use strict";function t(){var t=document.createElement("input");return t.setAttribute("type","range"),"text"!==t.type}function e(t,e){var i=Array.prototype.slice.call(arguments,2);return setTimeout(function(){return t.apply(null,i)},e)}function i(t,e){return e=e||100,function(){if(!t.debouncing){var i=Array.prototype.slice.apply(arguments);t.lastReturnVal=t.apply(window,i),t.debouncing=!0}return clearTimeout(t.debounceTimeout),t.debounceTimeout=setTimeout(function(){t.debouncing=!1},e),t.lastReturnVal}}function n(t){return!(0!==t.offsetWidth&&0!==t.offsetHeight&&t.open!==!1)}function s(t){for(var e=[],i=t.parentNode;n(i);)e.push(i),i=i.parentNode;return e}function o(t,e){function i(t){"undefined"!=typeof t.open&&(t.open=t.open?!1:!0)}var n=s(t),o=n.length,r=[],h=t[e];if(o){for(var a=0;o>a;a++)r[a]=n[a].style.display,n[a].style.display="block",n[a].style.height="0",n[a].style.overflow="hidden",n[a].style.visibility="hidden",i(n[a]);h=t[e];for(var l=0;o>l;l++)i(n[l]),n[l].style.display=r[l],n[l].style.height="",n[l].style.overflow="",n[l].style.visibility=""}return h}function r(t){return t===""+t}function h(t){return null!==t&&void 0!==t&&(r(t)&&isFinite(parseFloat(t))||isFinite(t))}function a(){if(!arguments.length)return null;for(var t=0,e=arguments.length;e>t;t++)if(h(arguments[t]))return arguments[t]}function l(t){return"[object Object]"===Object.prototype.toString.call(t)}function u(t,e){var i,n={};for(i in t)n[i]=t[i];for(i in e)n[i]=e[i];return n}function d(t,e){for(var i in e)t.style[i]=e[i];return t.style}function p(t,e){v(t,e)||(t.className+=" "+e)}function f(t,e){var i=" "+t.className.replace(/[\t\r\n]/g," ")+" ";if(v(t,e)){for(;i.indexOf(" "+e+" ")>=0;)i=i.replace(" "+e+" "," ");t.className=i.replace(/^\s+|\s+$/g,"")}}function c(t,e,i){for(i&&e(t);t.parentNode&&!e(t);)t=t.parentNode;return t}function m(t,e,i){if(!r(e))throw new TypeError("event name must be String");if(!(t instanceof HTMLElement))throw new TypeError("element must be HTMLElement");e=e.trim();var n=document.createEvent("CustomEvent");n.initCustomEvent(e,!1,!1,i),t.dispatchEvent(n)}function v(t,e){return new RegExp(" "+e+" ").test(" "+t.className+" ")}function g(t,e){t.parentNode.insertBefore(e,t.nextSibling)}function b(t,e,i){e.forEach(function(e){t[x]||(t[x]={}),t[x][e]||(t[x][e]=[]),t.addEventListener(e,i,!1),t[x][e].indexOf(i)<0&&t[x][e].push(i)})}function y(t,e,i){e.forEach(function(e){t.removeEventListener(e,i,!1);var n;t[x]&&t[x][e]&&(n=t[x][e].indexOf(i))>-1&&t[x][e].splice(n,1)})}function _(t){function e(t){t===i._startEventListener&&this.el.removeEventListener(this.eventName,t,!1)}if(t[x]){var i=this;for(var n in t[x])t[x][n].forEach(e,{eventName:n,el:t});t[x]={}}}function E(t,e){var i,n,s;return this.element=t,this.options=u(X,e),this.polyfill=this.options.polyfill,this.onInit=this.options.onInit,this.onSlide=this.options.onSlide,this.onSlideStart=this.options.onSlideStart,this.onSlideEnd=this.options.onSlideEnd,this.onSlideEventsCount=-1,this.isInteractsNow=!1,this.needTriggerEvents=!1,!this.polyfill&&L?!1:(this.options.buffer=this.options.buffer||parseFloat(this.element.getAttribute("data-buffer")),this.identifier="js-"+C+"-"+P++,this.min=a(this.options.min,parseFloat(this.element.getAttribute("min")),i=0),this.max=a(this.options.max,parseFloat(this.element.getAttribute("max")),n=S),this.value=a(this.options.value,this.element.value,parseFloat(this.element.value||this.min+(this.max-this.min)/2)),this.step=a(this.options.step,parseFloat(this.element.getAttribute("step"))||(s=1)),this.percent=null,this._updatePercentFromValue(),this.toFixed=this._toFixed(this.step),this.fill=document.createElement("div"),this.fill.className=this.options.fillClass,this.handle=document.createElement("div"),this.handle.className=this.options.handleClass,this.range=document.createElement("div"),this.range.className=this.options.rangeClass,this.range.id=this.identifier,this.range.appendChild(this.handle),this.range.appendChild(this.fill),this.options.bufferClass&&(this.buffer=document.createElement("div"),this.buffer.className=this.options.bufferClass,this.range.appendChild(this.buffer)),h(this.options.value)&&(this._setValue(this.options.value,!0),this.element.value=this.options.value),h(this.options.buffer)&&this.element.setAttribute("data-buffer",this.options.buffer),(h(this.options.min)||i)&&this.element.setAttribute("min",""+this.min),(h(this.options.max)||n)&&this.element.setAttribute("max",""+this.max),(h(this.options.step)||s)&&this.element.setAttribute("step",""+this.step),g(this.element,this.range),d(this.element,{position:"absolute",width:"1px",height:"1px",overflow:"hidden",opacity:"0"}),this._handleDown=this._handleDown.bind(this),this._handleMove=this._handleMove.bind(this),this._handleEnd=this._handleEnd.bind(this),this._startEventListener=this._startEventListener.bind(this),this._changeEventListener=this._changeEventListener.bind(this),this._handleResize=this._handleResize.bind(this),this._init(),window.addEventListener("resize",this._handleResize,!1),b(document,this.options.startEvent,this._startEventListener),void this.element.addEventListener("change",this._changeEventListener,!1))}var x="eventListenerList",w=new RegExp("/[\\n\\t]/","g"),S=100,N=300,F=50,C="rangeSlider",P=0,L=t(),X={polyfill:!0,rangeClass:"rangeSlider",disabledClass:"rangeSlider--disabled",fillClass:"rangeSlider__fill",bufferClass:"rangeSlider__buffer",handleClass:"rangeSlider__handle",startEvent:["mousedown","touchstart","pointerdown"],moveEvent:["mousemove","touchmove","pointermove"],endEvent:["mouseup","touchend","pointerup"],min:null,max:null,step:null,value:null,buffer:null,borderRadius:10};return E.prototype.constructor=E,E.prototype._toFixed=function(t){return(t+"").replace(".","").length-1},E.prototype._init=function(){this.onInit&&"function"==typeof this.onInit&&this.onInit(),this._update()},E.prototype._updatePercentFromValue=function(){this.percent=(this.value-this.min)/(this.max-this.min)},E.prototype._startEventListener=function(t,e){var i=this,n=t.target,s=!1;c(n,function(t){return s=t.id===i.identifier&&!v(t,i.options.disabledClass)},!0),s&&this._handleDown(t,e)},E.prototype._changeEventListener=function(t,e){if(!e||e.origin!==this.identifier){var i=t.target.value,n=this._getPositionFromValue(i);this._setPosition(n)}},E.prototype._update=function(){this.handleWidth=o(this.handle,"offsetWidth"),this.rangeWidth=o(this.range,"offsetWidth"),this.maxHandleX=this.rangeWidth-this.handleWidth,this.grabX=this.handleWidth/2,this.position=this._getPositionFromValue(this.value),this.element.disabled?p(this.range,this.options.disabledClass):f(this.range,this.options.disabledClass),this._setPosition(this.position),this.options.bufferClass&&this.options.buffer&&this._setBufferPosition(this.options.buffer),this._updatePercentFromValue(),this.element.dispatchEvent(new Event("change"))},E.prototype._handleResize=function(){var t=this;return i(function(){e(function(){t._update()},N)},F)()},E.prototype._handleDown=function(t){if(this.isInteractsNow=!0,t.preventDefault(),b(document,this.options.moveEvent,this._handleMove),b(document,this.options.endEvent,this._handleEnd),!((" "+t.target.className+" ").replace(w," ").indexOf(this.options.handleClass)>-1)){var e=this._getRelativePosition(t),i=this.range.getBoundingClientRect().left,n=this._getPositionFromNode(this.handle)-i;this._setPosition(e-this.grabX),e>=n&&et?e:t>i?i:t},E.prototype._setPosition=function(t){var e,i;e=this._getValueFromPosition(this._cap(t,0,this.maxHandleX)),i=this._getPositionFromValue(e),this.fill.style.width=i+this.grabX+"px",this.handle.style.left=i+"px",this._setValue(e),this.position=i,this.value=e,this._updatePercentFromValue(),(this.isInteractsNow||this.needTriggerEventss)&&(this.onSlideStart&&"function"==typeof this.onSlideStart&&0===this.onSlideEventsCount&&this.onSlideStart(this.value,this.percent,this.position),this.onSlide&&"function"==typeof this.onSlide&&this.onSlide(this.value,this.percent,this.position)),this.onSlideEventsCount++},E.prototype._setBufferPosition=function(t){var e,i,n,s=!0;if(isFinite(t))t=parseFloat(t);else{if(!r(t))return void console.warn("New position must be XXpx or XX%");t.indexOf("px")>0&&(s=!1),t=parseFloat(t)}return isNaN(t)?void console.warn("New position is NaN"):this.options.bufferClass?(e=s?t:t/this.rangeWidth*100,0>e&&(e=0),e>100&&(e=100),this.options.buffer=e,i=this.options.borderRadius/this.rangeWidth*100,n=e-i,0>n&&(n=0),this.buffer.style.width=n+"%",this.buffer.style.left=.5*i+"%",void this.element.setAttribute("data-buffer",e)):void console.warn("You disabled buffer, it's className is empty")},E.prototype._getPositionFromNode=function(t){for(var e=0;null!==t;)e+=t.offsetLeft,t=t.offsetParent;return e},E.prototype._getRelativePosition=function(t){var e=this.range.getBoundingClientRect().left,i=0;return"undefined"!=typeof t.pageX?i=t.touches&&t.touches.length?t.touches[0].pageX:t.pageX:"undefined"!=typeof t.originalEvent.clientX?i=t.originalEvent.clientX:t.originalEvent.touches&&t.originalEvent.touches[0]&&"undefined"!=typeof t.originalEvent.touches[0].clientX?i=t.originalEvent.touches[0].clientX:t.currentPoint&&"undefined"!=typeof t.currentPoint.x&&(i=t.currentPoint.x),i-e},E.prototype._getPositionFromValue=function(t){var e,i;return e=(t-this.min)/(this.max-this.min),i=e*this.maxHandleX},E.prototype._getValueFromPosition=function(t){var e,i;return e=t/(this.maxHandleX||1),i=this.step*Math.round(e*(this.max-this.min)/this.step)+this.min,Number(i.toFixed(this.toFixed))},E.prototype._setValue=function(t,e){(t!==this.value||e)&&(this.element.value=t,this.value=t,m(this.element,"input",{origin:this.identifier}))},E.prototype.update=function(t,e){return e&&(this.needTriggerEvents=!0),l(t)&&(h(t.min)&&(this.element.setAttribute("min",""+t.min),this.min=t.min),h(t.max)&&(this.element.setAttribute("max",""+t.max),this.max=t.max),h(t.step)&&(this.element.setAttribute("step",""+t.step),this.step=t.step,this.toFixed=this._toFixed(t.step)),h(t.buffer)&&this._setBufferPosition(t.buffer),h(t.value)&&this._setValue(t.value)),this._update(),this.onSlideEventsCount=0,this.needTriggerEvents=!1,this},E.prototype.destroy=function(){_.call(this,document),window.removeEventListener("resize",this._handleResize,!1),this.element.removeEventListener("change",this._changeEventListener,!1),this.element.style.cssText="",delete this.element[C],this.range&&this.range.parentNode.removeChild(this.range)},E.create=function(t,e){function i(t){var i=t[C];i||(i=new E(t,e),t[C]=i)}t.length?Array.prototype.slice.call(t).forEach(function(t){i(t)}):i(t)},E}); \ No newline at end of file diff --git a/src/rangeSlider.js b/src/rangeSlider.js index 7a7d9ba..1c2f65e 100644 --- a/src/rangeSlider.js +++ b/src/rangeSlider.js @@ -274,7 +274,8 @@ throw new TypeError('element must be HTMLElement'); } name = name.trim(); - var event = new CustomEvent(name, data); + var event = document.createEvent('CustomEvent'); + event.initCustomEvent(name, false, false, data); el.dispatchEvent(event); }