diff --git a/dist/index.js b/dist/index.js index 8f2933b..b2ef7ab 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,7 +1,7 @@ (function(){ var ldslider; ldslider = function(opt){ - var root, ro, i$, to$, i, that, handle, el, mouse, this$ = this; + var root, i$, to$, i, that, handle, ro, el, mouse, this$ = this; opt == null && (opt = {}); this.evtHandler = {}; this.opt = import$({ @@ -18,12 +18,6 @@ this.root = root = typeof opt.root === 'string' ? document.querySelector(opt.root) : opt.root; - if (typeof ResizeObserver != 'undefined' && ResizeObserver !== null) { - ro = new ResizeObserver(function(es){ - return this$.set(this$.get()); - }); - ro.observe(this.root); - } if (this.root.tagName === 'INPUT') { this.input = this.root; ld$.attr(this.input, 'type', 'hidden'); @@ -64,6 +58,12 @@ this.input.addEventListener('change', handle); this.input.addEventListener('input', handle); } + if (typeof ResizeObserver != 'undefined' && ResizeObserver !== null) { + ro = new ResizeObserver(function(es){ + return this$.set(this$.get()); + }); + ro.observe(this.root); + } this.root._ldrs = this; this.root.classList.add('ldrs'); this.root.innerHTML = "
\n\n\n"; diff --git a/dist/index.min.js b/dist/index.min.js index ff1e71a..5303938 100644 --- a/dist/index.min.js +++ b/dist/index.min.js @@ -1 +1 @@ -!function(){var t;function r(t,i){var e,s={}.hasOwnProperty;for(e in i)s.call(i,e)&&(t[e]=i[e]);return t}(t=function(t){var i,e,s,n,o,l=this;if(null==t&&(t={}),this.evtHandler={},this.opt=r({min:0,max:100,from:0,to:0,step:1},t),this.val={to:0,from:0},this.root=t="string"==typeof t.root?document.querySelector(t.root):t.root,"undefined"!=typeof ResizeObserver&&null!==ResizeObserver&&new ResizeObserver(function(t){return l.set(l.get())}).observe(this.root),"INPUT"===this.root.tagName){for(this.input=this.root,ld$.attr(this.input,"type","hidden"),this.root=t=document.createElement("div"),this.input.parentNode.insertBefore(this.root,this.input),i=0,e=this.input.classList.length;ithis.opt.limitMax&&(t=this.opt.limitMax)),this.val[c]=t,v[c]=p);if(p=v[o],t=this.val[o],f=this.range?Math.min(v.from,v.to)+.5:0,x=this.range?Math.max(v.from,v.to)-f+.5:v.from,r.getBoundingClientRect(),r.innerText=this.label.ptr(Math.round(1e4*t)/1e4),r.style.left=.01*p*h.width*100/h.width+"%",r.style.transform="translate(-50%,0)",a.style.left=p+"%",this.el.b.fg.style.width=x+"%",this.el.b.fg.style.left=f+"%",t!==l&&i&&this.fire("change",this.range?this.val:this.val[o]),this.input)return this.updateInput({now:!s})}}),"undefined"!=typeof module&&null!==module?module.exports=t:"undefined"!=typeof window&&null!==window&&(window.ldslider=t)}.call(this);
+!function(){var t;function r(t,i){var e,s={}.hasOwnProperty;for(e in i)s.call(i,e)&&(t[e]=i[e]);return t}(t=function(t){var i,e,s,n,o,l=this;if(null==t&&(t={}),this.evtHandler={},this.opt=r({min:0,max:100,from:0,to:0,step:1},t),this.val={to:0,from:0},this.root=t="string"==typeof t.root?document.querySelector(t.root):t.root,"INPUT"===this.root.tagName){for(this.input=this.root,ld$.attr(this.input,"type","hidden"),this.root=t=document.createElement("div"),this.input.parentNode.insertBefore(this.root,this.input),i=0,e=this.input.classList.length;i this.opt.limitMax&&(t=this.opt.limitMax)),this.val[c]=t,v[c]=p);if(p=v[o],t=this.val[o],f=this.range?Math.min(v.from,v.to)+.5:0,x=this.range?Math.max(v.from,v.to)-f+.5:v.from,r.getBoundingClientRect(),r.innerText=this.label.ptr(Math.round(1e4*t)/1e4),r.style.left=.01*p*h.width*100/h.width+"%",r.style.transform="translate(-50%,0)",a.style.left=p+"%",this.el.b.fg.style.width=x+"%",this.el.b.fg.style.left=f+"%",t!==l&&i&&this.fire("change",this.range?this.val:this.val[o]),this.input)return this.updateInput({now:!s})}}),"undefined"!=typeof module&&null!==module?module.exports=t:"undefined"!=typeof window&&null!==window&&(window.ldslider=t)}.call(this);
diff --git a/src/index.ls b/src/index.ls
index 1588353..27d6772 100644
--- a/src/index.ls
+++ b/src/index.ls
@@ -2,9 +2,6 @@ ldslider = (opt={}) ->
@ <<< evt-handler: {}, opt: {min: 0, max: 100, from: 0, to: 0, step: 1} <<< opt
@val = {to: 0, from: 0}
@root = root = if typeof(opt.root) == \string => document.querySelector(opt.root) else opt.root
- if ResizeObserver? =>
- ro = new ResizeObserver (es) ~> @set @get!
- ro.observe @root
if @root.tagName == \INPUT =>
@input = @root
ld$.attr @input, \type, \hidden
@@ -28,6 +25,10 @@ ldslider = (opt={}) ->
@input.addEventListener \change, handle
@input.addEventListener \input, handle
+ if ResizeObserver? =>
+ ro = new ResizeObserver (es) ~> @set @get!
+ ro.observe @root
+
@root._ldrs = @
@root.classList.add \ldrs
@root.innerHTML = """
diff --git a/web/static/assets/lib/ldslider/dev/index.js b/web/static/assets/lib/ldslider/dev/index.js
index 8f2933b..b2ef7ab 100644
--- a/web/static/assets/lib/ldslider/dev/index.js
+++ b/web/static/assets/lib/ldslider/dev/index.js
@@ -1,7 +1,7 @@
(function(){
var ldslider;
ldslider = function(opt){
- var root, ro, i$, to$, i, that, handle, el, mouse, this$ = this;
+ var root, i$, to$, i, that, handle, ro, el, mouse, this$ = this;
opt == null && (opt = {});
this.evtHandler = {};
this.opt = import$({
@@ -18,12 +18,6 @@
this.root = root = typeof opt.root === 'string'
? document.querySelector(opt.root)
: opt.root;
- if (typeof ResizeObserver != 'undefined' && ResizeObserver !== null) {
- ro = new ResizeObserver(function(es){
- return this$.set(this$.get());
- });
- ro.observe(this.root);
- }
if (this.root.tagName === 'INPUT') {
this.input = this.root;
ld$.attr(this.input, 'type', 'hidden');
@@ -64,6 +58,12 @@
this.input.addEventListener('change', handle);
this.input.addEventListener('input', handle);
}
+ if (typeof ResizeObserver != 'undefined' && ResizeObserver !== null) {
+ ro = new ResizeObserver(function(es){
+ return this$.set(this$.get());
+ });
+ ro.observe(this.root);
+ }
this.root._ldrs = this;
this.root.classList.add('ldrs');
this.root.innerHTML = " this.opt.limitMax&&(t=this.opt.limitMax)),this.val[c]=t,v[c]=p);if(p=v[o],t=this.val[o],f=this.range?Math.min(v.from,v.to)+.5:0,x=this.range?Math.max(v.from,v.to)-f+.5:v.from,r.getBoundingClientRect(),r.innerText=this.label.ptr(Math.round(1e4*t)/1e4),r.style.left=.01*p*h.width*100/h.width+"%",r.style.transform="translate(-50%,0)",a.style.left=p+"%",this.el.b.fg.style.width=x+"%",this.el.b.fg.style.left=f+"%",t!==l&&i&&this.fire("change",this.range?this.val:this.val[o]),this.input)return this.updateInput({now:!s})}}),"undefined"!=typeof module&&null!==module?module.exports=t:"undefined"!=typeof window&&null!==window&&(window.ldslider=t)}.call(this);
+!function(){var t;function r(t,i){var e,s={}.hasOwnProperty;for(e in i)s.call(i,e)&&(t[e]=i[e]);return t}(t=function(t){var i,e,s,n,o,l=this;if(null==t&&(t={}),this.evtHandler={},this.opt=r({min:0,max:100,from:0,to:0,step:1},t),this.val={to:0,from:0},this.root=t="string"==typeof t.root?document.querySelector(t.root):t.root,"INPUT"===this.root.tagName){for(this.input=this.root,ld$.attr(this.input,"type","hidden"),this.root=t=document.createElement("div"),this.input.parentNode.insertBefore(this.root,this.input),i=0,e=this.input.classList.length;i this.opt.limitMax&&(t=this.opt.limitMax)),this.val[c]=t,v[c]=p);if(p=v[o],t=this.val[o],f=this.range?Math.min(v.from,v.to)+.5:0,x=this.range?Math.max(v.from,v.to)-f+.5:v.from,r.getBoundingClientRect(),r.innerText=this.label.ptr(Math.round(1e4*t)/1e4),r.style.left=.01*p*h.width*100/h.width+"%",r.style.transform="translate(-50%,0)",a.style.left=p+"%",this.el.b.fg.style.width=x+"%",this.el.b.fg.style.left=f+"%",t!==l&&i&&this.fire("change",this.range?this.val:this.val[o]),this.input)return this.updateInput({now:!s})}}),"undefined"!=typeof module&&null!==module?module.exports=t:"undefined"!=typeof window&&null!==window&&(window.ldslider=t)}.call(this);