Skip to content

Commit

Permalink
fix bug: resizeObserver should be installed after root is correctly set
Browse files Browse the repository at this point in the history
  • Loading branch information
zbryikt committed Apr 2, 2022
1 parent eba7411 commit ac33b7e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
14 changes: 7 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -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$({
Expand All @@ -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');
Expand Down Expand Up @@ -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 = "<div class=\"bar\">\n <div class=\"cap\"></div>\n <div class=\"cap\"></div>\n <div class=\"bar-inner\">\n <div class=\"bk\"></div>\n <div class=\"fg\"></div>\n <div class=\"line lock\"></div>\n <div class=\"line p\"></div>\n <div class=\"hint p\"></div>\n <div class=\"line p alt\"></div>\n <div class=\"hint p alt\"></div>\n </div>\n</div>\n<div class=\"hint l\"></div>\n<div class=\"hint lock\"></div>\n<div class=\"hint r\"></div>";
Expand Down
2 changes: 1 addition & 1 deletion dist/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/index.ls
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = """
Expand Down
14 changes: 7 additions & 7 deletions web/static/assets/lib/ldslider/dev/index.js
Original file line number Diff line number Diff line change
@@ -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$({
Expand All @@ -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');
Expand Down Expand Up @@ -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 = "<div class=\"bar\">\n <div class=\"cap\"></div>\n <div class=\"cap\"></div>\n <div class=\"bar-inner\">\n <div class=\"bk\"></div>\n <div class=\"fg\"></div>\n <div class=\"line lock\"></div>\n <div class=\"line p\"></div>\n <div class=\"hint p\"></div>\n <div class=\"line p alt\"></div>\n <div class=\"hint p alt\"></div>\n </div>\n</div>\n<div class=\"hint l\"></div>\n<div class=\"hint lock\"></div>\n<div class=\"hint r\"></div>";
Expand Down
Loading

0 comments on commit ac33b7e

Please sign in to comment.